mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix: skip dropping search tools when server-side tool invocations enabled (Gemini 3+)
This commit is contained in:
parent
88de9ccdf8
commit
95f0fcd204
2 changed files with 35 additions and 1 deletions
|
|
@ -650,7 +650,12 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
urlContext,
|
||||
]
|
||||
)
|
||||
if gtool_func_declarations and has_search_tools:
|
||||
# Skip this check when include_server_side_tool_invocations is enabled
|
||||
# (Gemini 3+ supports tool combination natively via PR #24073).
|
||||
server_side_tool_invocations = optional_params.get(
|
||||
"include_server_side_tool_invocations", False
|
||||
)
|
||||
if gtool_func_declarations and has_search_tools and not server_side_tool_invocations:
|
||||
verbose_logger.warning(
|
||||
"Vertex AI does not support mixing function declarations with "
|
||||
"search tools (googleSearch, enterpriseWebSearch, urlContext, "
|
||||
|
|
|
|||
|
|
@ -2867,6 +2867,35 @@ def test_vertex_ai_function_tools_with_code_execution_preserved():
|
|||
assert "code_execution" in tool_keys
|
||||
|
||||
|
||||
def test_vertex_ai_gemini3_tool_combination_no_drop():
|
||||
"""
|
||||
Test that search tools are NOT dropped when include_server_side_tool_invocations
|
||||
is enabled (Gemini 3+ tool combination).
|
||||
"""
|
||||
v = VertexGeminiConfig()
|
||||
optional_params = {"include_server_side_tool_invocations": True}
|
||||
|
||||
tools = v._map_function(
|
||||
value=[
|
||||
{"enterpriseWebSearch": {}},
|
||||
{"urlContext": {}},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {"name": "my_func", "description": "A function"},
|
||||
},
|
||||
],
|
||||
optional_params=optional_params,
|
||||
)
|
||||
|
||||
tool_keys = set()
|
||||
for t in tools:
|
||||
tool_keys.update(t.keys())
|
||||
assert "function_declarations" in tool_keys
|
||||
assert "enterpriseWebSearch" in tool_keys
|
||||
assert "url_context" in tool_keys
|
||||
assert len(tools) == 3
|
||||
|
||||
|
||||
def test_vertex_ai_openai_web_search_tool_transformation():
|
||||
"""
|
||||
Test that OpenAI-style web_search and web_search_preview tools are transformed to googleSearch.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue