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
Example Code
Error Message and Stack Trace (if applicable)
Description
When using
ChatGooglefrom@langchain/googlewith both a built-in/server-side tool (e.g.{ googleSearch: {} }) and function calling tools, the Google Generative AI API returns a 400error requiring
tool_config.include_server_side_tool_invocationsto be set totrue.As per the docs (https://ai.google.dev/gemini-api/docs/tool-combination) we should be able to pass
includeServerSideToolInvocations: trueto 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