Your coding agent is connected to 25 MCP servers exposing about 300 tools, and tool definitions alone consume tens of thousands of tokens before the user’s request. Latency, cost and tool-selection accuracy are all suffering. What would you change?
Answer
Model answer, written in a candidate's voice
In short
- Measure first: tokens on definitions and intermediate results per task, tool-selection accuracy on labelled tasks, cache hit rate
- Load tools on demand: search/retrieval over the catalogue, namespacing, subsets handed to sub-agents instead of preloading everything
- Progressive disclosure: skills with short name/description in context, full instructions and scripts loaded only when relevant
- Code execution over tool calls: servers as code APIs imported in a sandbox, large intermediates filtered there (Anthropic reported ~150k to ~2k tokens)
- Keep the stable prefix byte-identical for prompt caching; note new risks of executing agent-written code (sandboxing, resource limits, monitoring)
In full
I’d start by measuring before changing anything: tokens spent on tool definitions and intermediate results per task, tool-selection accuracy on a labelled set of tasks, and prompt-cache hit rate, so I know what I’m actually fixing. Then I’d stop preloading all 300 definitions and instead give the agent a tool-search or retrieval step over the catalogue, with namespaced tools and subsets handed to sub-agents, so only the relevant handful enter context. I’d package procedures as skills — short name and description always in context, full instructions and scripts loaded only when relevant — and I’d prefer code execution over raw tool calls: present each server as a code API the agent imports in a sandbox, so large intermediate results are filtered there instead of pasted through the model (Anthropic reported one workflow falling from about 150k to 2k tokens). I’d keep the stable prefix byte-identical so prompt caching still hits, and I’d treat executing agent-written code as a new risk surface — sandboxing, resource limits, and monitoring — rather than a free win.
What a strong answer covers
- Measures first: tokens spent on definitions and intermediate results per task, tool-selection accuracy on labelled tasks, cache hit rate
- Loads tools on demand: tool search or retrieval over the catalogue, namespacing, and handing subsets to sub-agents instead of preloading everything
- Progressive disclosure: package procedures as skills whose short name and description sit in context while full instructions and scripts load only when relevant
- Code execution over tool calls: present servers as code APIs the agent imports, so large intermediate results are filtered in the sandbox rather than pasted through the model (Anthropic reported one workflow falling from about 150k to 2k tokens)
- Keeps the stable prefix byte-identical so prompt caching still hits, and notes the new risks of executing agent-written code (sandboxing, resource limits, monitoring)
Common mistakes
- Only trimming tool descriptions while still loading every tool on every call
- Adding code execution without a sandbox or resource limits
Follow-ups
- How would you evaluate whether on-demand tool loading hurts tool-selection accuracy?