Skip to content

Feature Request: Add Tool Search support for Google Vertex Anthropic provider #13337

@lzj960515

Description

@lzj960515

Description

Google Vertex AI's Anthropic API supports Tool Search functionality that allows Claude to automatically search and select appropriate tools from a large tool set. This feature is essential for applications with many tools, as it enables efficient tool selection without loading all tools at once.

However, the AI SDK's @ai-sdk/google-vertex/anthropic provider does not currently support this feature.

Evidence

I've tested the Tool Search functionality directly using the @anthropic-ai/vertex-sdk and it works as expected.

Test Code (working with native SDK)

import AnthropicVertex from '@anthropic-ai/vertex-sdk';

const vertexClient = new AnthropicVertex({
  projectId: 'pietra-ai',
  region: 'global',
  defaultHeaders: { 'anthropic-beta': 'web-search-2025-03-05' },
});

const msg = await vertexClient.messages.create({
  model: 'claude-sonnet-4-5',
  max_tokens: 1000,
  messages: [{
    role: 'user',
    content: [{ type: 'text', text: 'What is the weather in San Francisco?' }],
  }],
  tools: [
    {
      type: 'tool_search_tool_regex_20251119',
      name: 'tool_search_tool_regex',
    },
    {
      name: 'get_weather',
      description: 'Get the weather at a specific location',
      input_schema: {
        type: 'object',
        properties: {
          location: { type: 'string' },
          unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
        },
        required: ['location'],
      },
      defer_loading: true,
    },
  ],
  tool_choice: { type: 'auto' },
});

Test Result

The API correctly returns server_tool_use and tool_search_tool_result content blocks:

{
  "model": "claude-sonnet-4-5-20250929",
  "content": [
    {
      "type": "text",
      "text": "I'll search for weather-related tools to help you get the weather information for San Francisco."
    },
    {
      "type": "server_tool_use",
      "id": "srvtoolu_vrtx_0166J3cFJdiPG4vLWXa8e5az",
      "name": "tool_search_tool_regex",
      "input": {}
    },
    {
      "type": "tool_search_tool_result",
      "tool_use_id": "srvtoolu_vrtx_0166J3cFJdiPG4vLWXa8e5az",
      "content": {}
    },
    {
      "type": "text",
      "text": "Great! I found a weather function. Let me get the current weather in San Francisco for you."
    },
    {
      "type": "tool_use",
      "id": "toolu_vrtx_01QfYyuFYPymZDRJx7KVHEYC",
      "name": "get_weather",
      "input": {}
    }
  ],
  "stop_reason": "tool_use"
}

Feature Details

Google Vertex Anthropic API supports two Tool Search modes:

  1. Regex-based search (tool_search_tool_regex_20251119)
  2. BM25-based search (tool_search_tool_bm25_20251119)

Both work with the defer_loading option on tools, which allows tools to be lazily loaded when the model determines they are needed.

References

Related

This is particularly useful for applications with a large number of tools (100+), where loading all tools into context would be inefficient or exceed context limits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelfeatureNew feature or requestprovider/anthropicIssues related to the @ai-sdk/anthropic providerprovider/google-vertexIssues related to the @ai-sdk/google-vertex provider

    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