Skip to content

Tool Search

The ToolSearch capability handles discovery of tools marked with defer_loading=True, so agents with large toolsets only pay tokens for the tools the model needs. Like the provider-adaptive tools above, it picks the best path for the active model — native server-executed search on Anthropic and OpenAI Responses, a local search_tools function tool elsewhere — and is auto-injected into every agent with zero overhead when no deferred tools exist.

Pass an explicit ToolSearch to pick a specific strategy ('keywords', 'bm25', 'regex', or a custom callable) or tune the local fallback:

tool_search_capability.py
from pydantic_ai import Agent
from pydantic_ai.capabilities import ToolSearch

agent = Agent('anthropic:claude-sonnet-4-6', capabilities=[ToolSearch(strategy='keywords')])

See Tool Search for when to reach for it, the full strategy table, and provider support details.