Skip to content

v5 @ai-sdk/google custom tools are not available when useSearchGrounding is set to true #7173

@pavlo-tkhir

Description

@pavlo-tkhir

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",

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy