u/Defiant-Future-818

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.

https://preview.redd.it/hzlnxp2uvwxg1.png?width=895&format=png&auto=webp&s=ef18932fc5aed49bbaacecb82cdec1f6f6a47191

https://preview.redd.it/q22qhq2uvwxg1.png?width=435&format=png&auto=webp&s=127c5ab5826a7b17abbade49a05d65a153344d56

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

reddit.com
u/Defiant-Future-818 — 16 days ago