mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
fix(protocol): skip non-function Responses tools during cross-protocol bridging
Closes #95
This commit is contained in:
1 parent
a46de6fe29
commit
6d83806939
1 file changed
+9
-2
@@ -492,8 +492,15 @@ func decodeBridgeRequest(protocol Protocol, input map[string]any) (bridgeRequest
|
||||
}
|
||||
for i, raw := range jsonutil.SliceAt(input, "tools") {
|
||||
tool, ok := raw.(map[string]any)
|
||||
if !ok || jsonutil.StringAt(tool, "type") != "function" {
|
||||
return request, fmt.Errorf("tools[%d] must be a function tool", i)
|
||||
if !ok {
|
||||
return request, fmt.Errorf("tools[%d] must be an object", i)
|
||||
}
|
||||
// Built-in Responses tools (web_search, file_search, code_interpreter, …)
|
||||
// have no Chat/Anthropic equivalent; skip them during cross-protocol
|
||||
// bridging so requests that mix function tools with built-in plugins
|
||||
// still reach the upstream.
|
||||
if jsonutil.StringAt(tool, "type") != "function" {
|
||||
continue
|
||||
}
|
||||
request.Tools = append(request.Tools, bridgeTool{
|
||||
Name: jsonutil.StringAt(tool, "name"),
|
||||
|
||||
Reference in new issue
Block a user