Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
06cfb7c2
Commit
06cfb7c2
authored
Apr 01, 2026
by
YanzheL
Committed by
陈曦
Apr 08, 2026
Browse files
fix(antigravity): preserve google search with function tools
parent
ac28ca64
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/pkg/antigravity/request_transformer.go
View file @
06cfb7c2
...
@@ -730,13 +730,14 @@ func buildTools(tools []ClaudeTool) []GeminiToolDeclaration {
...
@@ -730,13 +730,14 @@ func buildTools(tools []ClaudeTool) []GeminiToolDeclaration {
})
})
}
}
if
len
(
funcDecls
)
==
0
{
var
declarations
[]
GeminiToolDeclaration
if
!
hasWebSearch
{
if
len
(
funcDecls
)
>
0
{
return
nil
declarations
=
append
(
declarations
,
GeminiToolDeclaration
{
}
FunctionDeclarations
:
funcDecls
,
})
// Web Search 工具映射
}
return
[]
GeminiToolDeclaration
{{
if
hasWebSearch
{
declarations
=
append
(
declarations
,
GeminiToolDeclaration
{
GoogleSearch
:
&
GeminiGoogleSearch
{
GoogleSearch
:
&
GeminiGoogleSearch
{
EnhancedContent
:
&
GeminiEnhancedContent
{
EnhancedContent
:
&
GeminiEnhancedContent
{
ImageSearch
:
&
GeminiImageSearch
{
ImageSearch
:
&
GeminiImageSearch
{
...
@@ -744,10 +745,11 @@ func buildTools(tools []ClaudeTool) []GeminiToolDeclaration {
...
@@ -744,10 +745,11 @@ func buildTools(tools []ClaudeTool) []GeminiToolDeclaration {
},
},
},
},
},
},
}}
})
}
if
len
(
declarations
)
==
0
{
return
nil
}
}
return
[]
GeminiToolDeclaration
{{
return
declarations
FunctionDeclarations
:
funcDecls
,
}}
}
}
backend/internal/pkg/antigravity/request_transformer_test.go
View file @
06cfb7c2
...
@@ -263,6 +263,29 @@ func TestBuildTools_CustomTypeTools(t *testing.T) {
...
@@ -263,6 +263,29 @@ func TestBuildTools_CustomTypeTools(t *testing.T) {
}
}
}
}
func
TestBuildTools_PreservesWebSearchAlongsideFunctions
(
t
*
testing
.
T
)
{
tools
:=
[]
ClaudeTool
{
{
Name
:
"get_weather"
,
Description
:
"Get weather information"
,
InputSchema
:
map
[
string
]
any
{
"type"
:
"object"
},
},
{
Type
:
"web_search_20250305"
,
Name
:
"web_search"
,
},
}
result
:=
buildTools
(
tools
)
require
.
Len
(
t
,
result
,
2
)
require
.
Len
(
t
,
result
[
0
]
.
FunctionDeclarations
,
1
)
require
.
Equal
(
t
,
"get_weather"
,
result
[
0
]
.
FunctionDeclarations
[
0
]
.
Name
)
require
.
NotNil
(
t
,
result
[
1
]
.
GoogleSearch
)
require
.
NotNil
(
t
,
result
[
1
]
.
GoogleSearch
.
EnhancedContent
)
require
.
NotNil
(
t
,
result
[
1
]
.
GoogleSearch
.
EnhancedContent
.
ImageSearch
)
require
.
Equal
(
t
,
5
,
result
[
1
]
.
GoogleSearch
.
EnhancedContent
.
ImageSearch
.
MaxResultCount
)
}
func
TestBuildGenerationConfig_ThinkingDynamicBudget
(
t
*
testing
.
T
)
{
func
TestBuildGenerationConfig_ThinkingDynamicBudget
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment