Skip to content

Gemini: INVALID_ARGUMENT when using built-in tools (GoogleSearch, etc.) with function calling #761

@jredl-va

Description

@jredl-va

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugThis is a bug-report. Bug-fix PRs use `C-enhancement` instead.D-chatmodel-implDomain: This is an issue related to particular ChatModel implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions