Skip to content

[FEATURE] Support for Tool Search Tool (defer_loading) to reduce token usage #124

Description

@dctmfoo

Summary

Add support for the Tool Search Tool beta feature to enable deferred tool loading and significantly reduce token consumption.

Problem

Currently, all tools (SDK + MCP) are loaded into context at session start. In my project, this consumes ~15,000-20,000 tokens for tool definitions alone, even when most tools aren't needed for the current query.

My current setup:

  • 12 SDK tools: ~6,000 tokens
  • 8 MCP tools (Google Workspace): ~5,285 tokens
  • Total tools overhead: ~11,000+ tokens per request

Proposed Solution

Support the defer_loading: true option and Tool Search Tool as documented at:
https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool

This would require:

  1. Beta header support in SDK options:

    • advanced-tool-use-2025-11-20
    • mcp-client-2025-11-20
  2. Option to pass defer_loading config for individual tools or as default

  3. Support for mcp_toolset with default_config for MCP servers:

{
  type: "mcp_toolset",
  mcp_server_name: "my-server",
  default_config: {
    defer_loading: true
  },
  configs: {
    "frequently_used_tool": { defer_loading: false }
  }
}

Expected Benefit

According to Anthropic's documentation:

  • Up to 85% reduction in tool token usage
  • Improved accuracy on tool selection with large tool libraries (Opus 4.5: 79.5% → 88.1%)

Workaround

Currently the only workaround is to manually reduce the number of tools configured, which limits functionality.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions