Skip to content

[Feature]: Missing TypeScript types for Tool Search functionality #939

@lzj960515

Description

@lzj960515

Problem

The @anthropic-ai/vertex-sdk package lacks TypeScript type definitions for the Tool Search functionality (tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119), even though the API fully supports these features.

Current Behavior

When using Tool Search tools, TypeScript compilation fails because the types are not defined:

tools: [
  {
    type: 'tool_search_tool_regex_20251119',  // TypeScript error: Type '"tool_search_tool_regex_20251119"' is not assignable to type '...'
    name: 'tool_search_tool_regex',
  } as any,  // Forced to use 'as any' workaround
  {
    name: 'get_weather',
    defer_loading: true,  // TypeScript error: 'defer_loading' does not exist in type 'Tool'
  } as any,  // Forced to use 'as any' workaround
]

The defer_loading property on tools also lacks type definition, forcing users to use as any type assertions.

Expected Behavior

The following types should be available:

  1. tool_search_tool_regex_20251119 - Regex-based tool search
  2. tool_search_tool_bm25_20251119 - BM25-based tool search
  3. defer_loading property on Tool type
  4. server_tool_use and tool_search_tool_result content block types in responses

Evidence

The API correctly handles these types at runtime:

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',
    } as any,
    {
      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,
    } as any,
  ],
  tool_choice: { type: 'auto' },
});

Runtime response shows Tool Search working correctly:

{
  "model": "claude-sonnet-4-5-20250929",
  "content": [
    {
      "type": "text",
      "text": "I'll search for weather-related tools..."
    },
    {
      "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": "tool_use",
      "id": "toolu_vrtx_01QfYyuFYPymZDRJx7KVHEYC",
      "name": "get_weather",
      "input": {}
    }
  ],
  "stop_reason": "tool_use"
}

Environment

  • @anthropic-ai/vertex-sdk: latest
  • TypeScript: 5.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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