Skip to content

Support includeServerSideToolInvocations flag for Google #10675

@navgarcha

Description

@navgarcha

Example Code

import { ChatGoogle } from '@langchain/google';
import { tool } from '@langchain/core/tools';
import { z } from 'zod';

const myTool = tool(
  async ({ query }) => `Result for ${query}`,
  {
    name: 'my_tool',
    description: 'A custom tool',
    schema: z.object({ query: z.string() }),
  },
);

const model = new ChatGoogle({ model: 'gemini-2.5-flash' });

// This fails with 400 Bad Request
const response = await model.bindTools([myTool, { googleSearch: {} }]).invoke(
  'Search for the latest news about AI',
);

Error Message and Stack Trace (if applicable)

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] Please enable
tool_config.include_server_side_tool_invocations to use Built-in tools with Function calling.

Description

When using ChatGoogle from @langchain/google with both a built-in/server-side tool (e.g. { googleSearch: {} }) and function calling tools, the Google Generative AI API returns a 400
error requiring tool_config.include_server_side_tool_invocations to be set to true.

As per the docs (https://ai.google.dev/gemini-api/docs/tool-combination) we should be able to pass includeServerSideToolInvocations: true to the tool config however it isnt possible to explicitly set this nor is it applied when a mix of built-in and custom tools is processed.

System Info

  • @langchain/google: 0.1.7
  • Node.js: v22

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions