cloudwego / cloudwego/eino-ext
Gemini: INVALID_ARGUMENT when using built-in tools (GoogleSearch, etc.) with function calling
- Dominant language
- Go
- Stars
- 811
- Forks
- 368
- Avg merge
- 16h 22m
- Merged PRs (30d)
- 13
Description
**Describe the bug**
When using built-in tools (e.g. `GoogleSearch`, `URLContext`) alongside custom function calling tools, the Gemini API returns:
```
Error 400, Message: Please enable tool_config.include_server_side_tool_invocations to use Built-in tools with Function calling., Status: INVALID_ARGUMENT
```
The `GenerateContentConfig.ToolConfig` needs `IncludeServerSideToolInvocations` set to `true` when both built-in tools and function declarations are present.
**To Reproduce**
1. Create a ChatModel with `EnableGoogleSearch` configured
2. Pass function calling tools via `schema.ToolInfo`
3. Call `Generate` or `Stream`
4. API returns `INVALID_ARGUMENT`
**Expected behavior**
The adapter should automatically set `ToolConfig.IncludeServerSideToolInvocations = true` when any built-in tool (GoogleSearch, URLContext, CodeExecution, ComputerUse, FileSearch, GoogleSearchRetrieval, GoogleMaps) is enabled alongside function declarations.
**Version:**
gemini@v0.1.29
**Environment:**
google.golang.org/genai v1.51.0+ (field added in this version)
**Additional context**
The `IncludeServerSideToolInvocations` field was added to `genai.ToolConfig` in `google.golang.org/genai` v1.51.0. The current `go.mod` pins `v1.36.0` which predates this field, so the fix also requires bumping the genai dependency.
Contributor guide
Research direction
Start in the Gemini adapter's handling of built-in tools and function declarations, then inspect go.mod for the google.golang.org/genai dependency. Reproduce the Generate and Stream cases with a built-in tool plus schema.ToolInfo, update the dependency as needed, and verify that both requests no longer return INVALID_ARGUMENT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, google-cloud
- Domain
- ai, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100