I think we were giving our agent way too many tools to choose from
Summary
Wrong endpoints and invented parameters traced back to 35 tool schemas filling the context, not to vague descriptions. Exposing a few commands and letting the agent look up endpoints on demand, with cached schemas, made debugging clearer.
What the comments say
Tool schemas are re-sent every turn: a few heavy MCP servers add 15-20K tokens per request, so a 20-turn run carries 300K of input for the tool list alone. Keep the discovered block at the tail so the prefix stays cached.
Injecting a newly discovered schema into the top-level tools array busts the prefix cache and forces a re-prefill of the whole history; return discovered schemas as plain text in a tool result and route calls through one generic executor instead.
Near-duplicate tools hurt more than the raw count: with 35 similar definitions the model picks between neighbours at random, and more description text makes it worse. Merge tools that differ by one argument into one with a mode field.
Cutting the tool list from 40 to 9 reduced wrong calls by more than the extra tools had added in accuracy, and the smaller list made prompt caching actually pay off.
Discovery needs the same controls as calls: which servers the agent may search and which tools it may bring back should be allow-listed per app, or discovery becomes a way around the list you set. Tool descriptions are server-written text the model reads as instruction.
Staging the toolset by task phase works better than mid-action discovery: give the agent only the tools the current step can use, and do discovery between steps.
Join the discussion
Was this useful to you?
Related
Claude Code has an experimental "Code Mode" that batches tool calls into JavaScript
r/ClaudeCode · Poatri_US
How Claude Code's Code Mode works
X · Arindam_1729
62 Claude sessions rebuilding my media library in 80 minutes
aaronorelup.com · Aaron Orelup
How do you make AI agents reliable when they use multiple tools?
r/AI_Agents · Aware-Resource9831
Support copilot keeps repeating dead SQL tool calls
r/AI_Agents · Lanky-Passenger-5777