-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Description
Description
When GoogleGenerativeAIProviderOptions useSearchGrounding is set to true, the tools defined in the user's code (e.g., in streamText) are overridden by a single googleSearch tool. As a result, the model can't call any other tools.
How to test:
const result = streamText({
model: google("gemini-2.5-flash"),
system: "
- Call the generateChatTitle tool to update the title
- Reply to the user
",
messages: convertedMessages,
providerOptions: {
google: {
useSearchGrounding: true,
thinkingConfig: {
thinkingBudget: 12000,
includeThoughts: true,
};
},
},
stopWhen: stepCountIs(5),
tools: {
generateChatTitle: tool({
description: "Generate a concise, descriptive title for the chat session based on the conversation.",
inputSchema: z.object({
title: z.string().describe("A concise title (3-6 words) that describes the main topic or purpose of the conversation"),
}),
execute: async ({ title }) => {
// Update the chat session name
return { success: true, title };
},
}),
},
});
Most likely because in google-prepare-tools.ts file tools are overridden with a new object:
if (useSearchGrounding) {
return {
tools: isGemini2
? { googleSearch: {} }
: {
googleSearchRetrieval:
!supportsDynamicRetrieval || !dynamicRetrievalConfig
? {}
: { dynamicRetrievalConfig },
},
toolConfig: undefined,
toolWarnings,
};
}
AI SDK Version
- "@ai-sdk/google": "^2.0.0-beta.6",
- "ai": "^5.0.0-beta.4",
leoni-q