
Most AI agents fail when you give them too many tools because the "system prompt" gets too long and the model gets confused (the "lost in the middle" problem).
I’ve been benchmarking an approach called ToolRouter that dynamically fetches tool schemas only when they are relevant, similar to the approach Claude Code uses internally. I managed to get a 128-tool environment down from 287,000 tokens to just 3,500 tokens of initial context.
It’s part of the mcp-ts library I’m building. If you're struggling with agent context limits or high API costs, and If you're already using the AG-UI protocol to bridge your agents to frontends like CopilotKit, this will certainly help you.
Check it out here: https://github.com/zonlabs/mcp-ts
Benchmark results: Link to benchmarks