fix(gemini): preserve google search in Claude compat tools

This commit is contained in:
YanzheL
2026-04-01 00:33:39 +08:00
parent c8cfad7c00
commit 0ebe0ce585
2 changed files with 61 additions and 5 deletions

View File

@@ -164,6 +164,35 @@ func TestConvertClaudeToolsToGeminiTools_CustomType(t *testing.T) {
}
}
func TestConvertClaudeToolsToGeminiTools_PreservesWebSearchAlongsideFunctions(t *testing.T) {
tools := []any{
map[string]any{
"name": "get_weather",
"description": "Get weather info",
"input_schema": map[string]any{"type": "object"},
},
map[string]any{
"type": "web_search_20250305",
"name": "web_search",
},
}
result := convertClaudeToolsToGeminiTools(tools)
require.Len(t, result, 2)
functionDecl, ok := result[0].(map[string]any)
require.True(t, ok)
funcDecls, ok := functionDecl["functionDeclarations"].([]any)
require.True(t, ok)
require.Len(t, funcDecls, 1)
searchDecl, ok := result[1].(map[string]any)
require.True(t, ok)
googleSearch, ok := searchDecl["googleSearch"].(map[string]any)
require.True(t, ok)
require.Empty(t, googleSearch)
}
func TestGeminiHandleNativeNonStreamingResponse_DebugDisabledDoesNotEmitHeaderLogs(t *testing.T) {
gin.SetMode(gin.TestMode)
logSink, restore := captureStructuredLog(t)