Topic 3 of 5 · 5 min read
Tool search and deferred tool loading
Goal: Decide which tools to load always and which to defer behind a search or skill, and predict the effect on context and accuracy.
Load the few tools the agent uses all the time, and make the rest findable on demand instead of always visible. The agent then sees a small list each turn and pulls in a definition only when it needs it.
Check yourself · 1 of 3
In an agent with many MCP tools, what does deferred tool loading do?
Why it matters
If every tool definition is sent on every turn, a large catalogue (dozens of tools across several servers) uses much of the window and makes selection harder. Anthropic's advanced tool use post describes a tool search tool: tools are marked as deferred, the model searches by keyword or description, and only the matching definitions are loaded into context. Anthropic reports large savings in context and better accuracy on large tool sets; read the post for its measurements rather than assuming a number for your setup. The Claude docs describe how to mark tools as deferred. Other agents use similar ideas: skills that load instructions when relevant, or giving the agent code to call tools, as in Anthropic's code execution with MCP article.
How to decide: always or deferred
- List every tool and count how often each was called in recent sessions.
- Always load tools used in most sessions (read file, run shell, edit) and tools whose absence would make the agent not know what it can do.
- Defer tools used rarely or for one kind of job (a deploy tool, a data export tool, an admin API).
- Write good search text. Deferred tools are found by name and description, so these must contain the words a user would use.
- Test. Run the same tasks with and without deferral. Compare context used, correct tool picks and turns taken.
Before and after
A plan for an internal agent with sixty tools:
Before: all 60 definitions loaded every turn.
After: 8 core tools always loaded (files, shell, git, search_tools).
52 tools deferred; found by search_tools("refund"), search_tools("deploy").
The agent starts each task with a short list. When asked to refund an order, it searches, loads the refund tool and uses it.
What goes wrong
- Deferring a tool the agent needs every time. It pays a search step on each task and sometimes forgets to search.
- Poor descriptions. If the tool is called
proc_xwith no description, search will not find it and the agent will conclude it does not exist. - Trusting it blindly. Search adds a step and can return the wrong tool. Measure accuracy on your own tasks.
- Confusing it with security. A deferred tool is still available once found; use permissions to forbid actions.
Examples
Splitting a tool catalogue
{
"always": ["read_file", "edit_file", "run_shell", "git_diff", "search_tools"],
"deferred": ["create_refund", "export_report", "deploy_staging", "rotate_api_key"]
}
The first group is used almost every session. The second group is used on a small share of tasks and found by search when asked for.
A missed tool
The agent is asked to "cancel the subscription" and answers that it has no such capability. The deferred tool is named end_plan with the description Ends a plan. The search never matched. Rename it cancel_subscription and describe it with the words customers use.
Key points
- Deferred loading keeps a small set of tools visible and loads other definitions only when the model searches for them.
- Always load the tools used in most sessions; defer the rare, job-specific ones.
- Search quality depends on tool names and descriptions, so write them with the words users and tasks actually contain.
- Skills and code execution are related ways to keep detail out of the window until it is needed.
- Measure context used, correct picks and turns before and after; deferral adds a step and is not free of errors.
- Deferring a tool hides it from the list but is not a permission control.
Common mistakes
- Deferring everything, including tools used on every task.
- Leaving deferred tools with terse or internal names that a search cannot match.
- Adopting deferral without testing accuracy on real tasks.
- Treating deferral as access control instead of setting permissions.
Check yourself · 2 of 3
Which tool is the best candidate to load always rather than defer?
Check yourself · 3 of 3
An agent says it cannot cancel subscriptions, but a deferred tool named end_plan does that. What is the most likely cause and fix?
Practice items, not counted towards your mastery.
Start here
- Introducing advanced tool use (Anthropic) (opens in a new tab)ArticleFree
Shows tool search, programmatic tool calling and tool-use examples, with Anthropic's own measurements of context saved.
- Code execution with MCP (Anthropic) (opens in a new tab)ArticleFree
Explains why many MCP tool definitions and large intermediate results waste context, and the code-execution fix.
- Tool search tool (Claude docs) (opens in a new tab)DocsFree
The API reference for deferring tool definitions and loading them on demand.