fix: skip FunctionCallingConfig when only native tools are present (#7407)

* fix: skip FunctionCallingConfig when only native tools are present

When native tools (google_search, url_context) are enabled without any
function_declarations, _prepare_query_config was still creating a
FunctionCallingConfig, which makes Gemini API return 400 INVALID_ARGUMENT.

Now we only set tool_config when tool_list actually contains
function_declarations.

Fixes #7406

* style: ruff format
This commit is contained in:
Yufeng He
2026-04-08 11:19:47 +08:00
committed by GitHub
parent 301df11102
commit 1ab925ed9f
@@ -215,7 +215,8 @@ class ProviderGoogleGenAI(Provider):
]
tool_config = None
if tools and tool_list:
has_func_decl = tool_list and any(t.function_declarations for t in tool_list)
if has_func_decl:
tool_config = types.ToolConfig(
function_calling_config=types.FunctionCallingConfig(
mode=(