feat(translator): map Claude web search tool type to Codex web_search

- Added special handling to replace `web_search_20250305` tool type with `{"type":"web_search"}` in Claude request processing.
This commit is contained in:
Luis Pater
2025-10-15 09:32:12 +08:00
parent c945e35983
commit 4576f9915b

View File

@@ -186,6 +186,12 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
shortMap := buildShortNameMap(names) shortMap := buildShortNameMap(names)
for i := 0; i < len(toolResults); i++ { for i := 0; i < len(toolResults); i++ {
toolResult := toolResults[i] toolResult := toolResults[i]
// Special handling: map Claude web search tool to Codex web_search
if toolResult.Get("type").String() == "web_search_20250305" {
// Replace the tool content entirely with {"type":"web_search"}
template, _ = sjson.SetRaw(template, "tools.-1", `{"type":"web_search"}`)
continue
}
tool := toolResult.Raw tool := toolResult.Raw
tool, _ = sjson.Set(tool, "type", "function") tool, _ = sjson.Set(tool, "type", "function")
// Apply shortened name if needed // Apply shortened name if needed