Merge pull request #2491 from mpfo0106/feature/claude-code-safe-alignment-sentinels

test(claude): add compatibility sentinels and centralize builtin fallback handling
This commit is contained in:
Luis Pater
2026-04-06 09:27:08 +08:00
committed by GitHub
9 changed files with 243 additions and 6 deletions

View File

@@ -951,12 +951,9 @@ func applyClaudeToolPrefix(body []byte, prefix string) []byte {
return body
}
// Collect built-in tool names (those with a non-empty "type" field) so we can
// skip them consistently in both tools and message history.
builtinTools := map[string]bool{}
for _, name := range []string{"web_search", "code_execution", "text_editor", "computer"} {
builtinTools[name] = true
}
// Collect built-in tool names from the authoritative fallback seed list and
// augment it with any typed built-ins present in the current request body.
builtinTools := helps.AugmentClaudeBuiltinToolRegistry(body, nil)
if tools := gjson.GetBytes(body, "tools"); tools.Exists() && tools.IsArray() {
tools.ForEach(func(index, tool gjson.Result) bool {