Agents pick the wrong tool at scale because every tool definition competes in one prompt. Anthropic's documentation says Claude's selection accuracy degrades once you exceed 30 to 50 tools and that a five-server MCP setup can use about 55k tokens of definitions before any work starts; OpenAI recommends fewer than 20 functions available at the start of a turn. In the RAG-MCP study, retrieving tools before the call raised selection accuracy from 13.62% to 43.13% and cut prompt tokens by over 50%. The fix is architectural: search the catalog, load only the 3 to 10 relevant definitions, namespace names by service, rewrite descriptions to name their confusable siblings, and gate tools by task phase. Before changing anything, build a labeled set of 200 real requests and measure retrieval recall and selection precision separately.
An agent calls the wrong tool at scale because every tool definition competes for the model's attention in a single prompt, and past a few dozen tools the near-duplicates start winning. The fix is not a better model or a longer system prompt. It is to search the catalog first and load only the handful of definitions relevant to the current request, with names and descriptions written so the model can tell siblings apart.
The thresholds are lower than most teams expect. Anthropic's tool search documentation says Claude's selection accuracy degrades once you exceed 30 to 50 available tools, and that a typical five-server MCP setup (GitHub, Slack, Sentry, Grafana, Splunk) uses about 55k tokens of definitions before Claude does any work. OpenAI's function calling guide says to aim for fewer than 20 functions available at the start of a turn. Three or four MCP servers plus your internal APIs put you past both lines.
This post covers why accuracy drops, the search-then-load pattern and how the two major APIs implement it, RAG-MCP retrieval, namespacing, description rewrites, phase-based filtering, when to split into sub-agents, and how to measure all of it.
Why more tools means worse tool selection
A tool, in function-calling terms, is a name, a natural-language description and a JSON Schema for its parameters. All three, for every registered tool, are serialized into the prompt on every turn. Two separate penalties grow with the catalog.
Disambiguation. At ten tools the descriptions are usually distinct. At a hundred you almost certainly have clusters: search_documents, search_knowledge_base and query_index; create_ticket, create_issue and open_case. The model separates them using descriptions that were written to explain each tool in isolation, not to say when to choose it over its siblings.
Context load. The relevant definition is one of many, and every irrelevant one is still tokens the model reads and you pay for on every turn. At 55k tokens of definitions, a long conversation can spend more context on unused schemas than on the user's actual task, the same pressure described in our guide to context compaction for long-running agents.
Read the RAG-MCP row carefully. Retrieval more than tripled accuracy, but 43% is not a production number. Retrieval removes most of the haystack; the rest of this post is about the work that gets you from there to reliable.
The thresholds also come from frontier hosted models. If you run open-weight models on your own hardware, measure your own curve. Do not assume a smaller self-hosted model tolerates the same catalog size, and check that your serving stack's tool-call parser is not the actual failure, which we cover in empty tool calls from vLLM's reasoning parser.
What the research shows
| Source | Setup | Finding |
|---|---|---|
| Anthropic tool search docs | Claude with a growing tool library | Selection accuracy degrades past 30 to 50 tools |
| Anthropic tool search docs | Five MCP servers loaded up front | About 55k tokens of definitions; tool search cuts this by over 85% |
| OpenAI function calling guide | Recommendation | Fewer than 20 functions at the start of a turn |
| LongFuncEval (April 2025) | Long-context models, increasing number of tools | Performance drops of 7% to 85% as tools increase |
| RAG-MCP (May 2025) | MCP tool selection, retrieval vs all tools in prompt | 43.13% vs 13.62% accuracy; over 50% fewer prompt tokens |
Search-then-load: the fix that addresses both penalties
Split tool use into two phases:
The model now separates 3 to 10 candidates instead of 200, and you stop paying for unused schemas every turn. Both major APIs ship this pattern natively.
{
"tools": [
{ "type": "tool_search_tool_bm25_20251119", "name": "tool_search_tool_bm25" },
{
"name": "github_create_issue",
"description": "Create an issue in a GitHub repository. Use for bugs and feature requests tracked in GitHub. Do not use for Linear tickets (use linear_create_issue) or internal IT requests (use servicedesk_open_case).",
"input_schema": {
"type": "object",
"properties": {
"repo": { "type": "string", "description": "owner/name, for example acme/api" },
"title": { "type": "string" },
"body": { "type": "string" }
},
"required": ["repo", "title"]
},
"defer_loading": true
}
]
}Claude: tool search with deferred loading
You send every definition in tools, mark the ones that should not load up front with defer_loading: true, and add one of two search tools: tool_search_tool_regex_20251119, where Claude writes Python regex patterns, or tool_search_tool_bm25_20251119, where it writes natural language queries. Claude starts with only the search tool and non-deferred tools in context. When it searches, the API returns up to 5 matches by default as tool_reference blocks and expands them into full definitions. Limits worth knowing: up to 10,000 deferred tools per request, at least one tool must stay non-deferred, and Anthropic recommends keeping your 3 to 5 most-used tools non-deferred so common requests skip the search. Both search variants match against tool names, descriptions, argument names and argument descriptions, so the description is the retrieval target. For MCP servers connected through the MCP connector, set defer_loading once on the server's toolset configuration instead of per tool. If BM25 and regex are not good enough for your vocabulary, implement your own search tool (for example embedding-based) and return tool_reference blocks from it; the API expands them the same way.
OpenAI: tool search and namespaces
OpenAI's function calling guide offers a tool_search tool, supported on gpt-5.4 and later, which lets the model search for tools and add them to context, along with namespaces to group tools by domain and defer_loading on functions inside a namespace. Its guidance splits the job cleanly: the namespace description helps the model choose what to load, and the function description helps it use the loaded tool correctly.
Self-hosted models: build the search phase yourself
Open-weight models served from your own hardware have no server-side tool search, so the harness does it. Three implementations, in increasing robustness: For regulated deployments this is also the only option that keeps tool metadata, which often names internal systems, inside your perimeter. Run the embedding model locally; our guide to choosing an embedding model for RAG applies unchanged to tool descriptions.
- Domain rules. If tools cluster by system, match the request to a domain and expose only that domain's tools. Simple, and brittle on cross-domain requests.
- Embedding retrieval. Embed each tool's name, description and parameter descriptions, embed the request, take the top k. This is RAG-MCP, covered next.
- Small-model routing. A fast model reads the request plus a compressed catalog (names and one-line descriptions) and returns candidate names. Handles nuance embeddings miss, at the cost of an extra model call on the critical path.
RAG-MCP: retrieval-augmented tool selection
RAG-MCP applies document-RAG mechanics to tools:
The failure mode is the one every RAG practitioner knows: a missed retrieval is invisible. If the right tool is not in the top k, the model never sees it and either calls a wrong tool or answers without one. Three safeguards:
Namespacing across MCP servers
Connect a GitHub server, a Linear server and your internal API, and you get several tools named some variant of create, search and get. Retrieval does not fix that; it returns all of them, because they are all relevant.
github_create_issue, linear_create_issue, servicedesk_open_case. Anthropic's tool definition guide recommends exactly this, and its tool search guide notes that a consistent prefix lets one search match a whole group. Claude tool names must match ^[a-zA-Z0-9_-]{1,128}$, so use underscores or hyphens, not dots.create_pr, review_pr, merge_pr) into one tool with an action parameter, which removes a three-way choice entirely.Namespacing is also an access-control boundary. Different servers carry different trust levels, and a confused agent calling the wrong server's write tool is a security incident, not an accuracy miss. An MCP gateway is the natural place to enforce per-server allowlists and renames, and an AI security review of a write-capable agent should include which tools each phase can reach.
Rewriting tool descriptions for disambiguation
Both retrieval and the model's final choice read the description, which makes it the highest-leverage text in the system. Anthropic's guide calls detailed descriptions "by far the most important factor in tool performance" and recommends at least three to four sentences per tool, covering when to use it and when not to.
The shift is from describing a tool to distinguishing it:
Weak: "Searches the knowledge base for relevant documents."
Strong: "Searches internal product documentation and help articles for how-to and troubleshooting answers. Use for questions about how a product feature works. Do not use for source code (use code_search) or for customer records (use crm_search). Returns up to 10 article titles with URLs and a short excerpt."
Rules for a catalog rewrite:
Filtering tools by task phase
Most agents move through phases, and tools relevant in one are noise in another. A coding agent exploring a repository needs read and search tools; editing needs write tools; verifying needs a test runner. Which search tool you give the exploration phase matters too, since semantic code search over an indexed repo returns ranked chunks instead of whole files.
Filtering by phase means the active tool set changes as the agent's state advances, driven by an explicit plan step or by the node in an orchestration graph. It improves selection within each phase, and it gives you a stronger safety property than any prompt: write tools do not exist in a read-only phase, so they cannot be called there.
When to split into sub-agents
Routing has a ceiling. When a catalog spans genuinely different domains, data and permissions, one router behind one agent is fighting the architecture.
A sub-agent owns a small tool set, so it gets the catalog-scale problem at a tractable size, and you can still retrieve within it. A top-level orchestrator picks the sub-agent, which is the same routing decision one layer up. Our breakdown of the deep agents pattern with planners and sub-agents covers the orchestration side. Do not split early: each sub-agent adds a model hop and needs its own eval set.
| Signal | Keep one agent with routing | Split into sub-agents |
|---|---|---|
| Catalog shape | Large but one coherent domain | Several distinct domains |
| Permissions | Uniform trust level | Different access scopes per tool group |
| Context | Groups share context cleanly | One domain's context pollutes another |
| Failure isolation | A failure in one area is tolerable | Failures must be contained |
Measuring tool selection: retrieval recall and selection precision
Without an eval set you are tuning blind, and tool-selection regressions are easy to miss because a wrong-tool call often still produces a plausible answer. Build one before changing anything:
Every change (a description edit, a new k, a namespace rename, a model upgrade) runs against the set before it ships. When a tool call does go wrong in production, the agent still needs a path out, which our guide to agent tool failure recovery covers.
A migration order for a large-catalog agent
What predicts selection accuracy is the number of tools the model has to choose between in context, not the number registered in your system. Keep the first number small and stable and a 500-tool agent behaves much like a 15-tool one. This is a core part of the agent work we do when we build production agents on client infrastructure. For the protocol plumbing behind multiple servers, see the MCP developer guide, and for the rest of the agent stack, the AI agents pillar.
This week, export a day of tool-call logs, count how many tools were in context on each call, and pull the 20 requests where the agent called a tool and then immediately called a different one. Those 20 are the start of your eval set.
FAQ
Quick answers to the questions this post tends to raise.



