MCP tool bloat is a hidden cost bug; Pi 1.0's Codemode cuts ~40% of tokens

大模型之路 · wechat · 2026-10-20

The article examines the hidden cost of hooking many MCP tools into coding agents: every tool's JSON definition sits in the system prompt, gets re-read and re-billed each turn, and scales linearly with conversation length—often mistaken for "models are just expensive." Pi 1.0 tackles it three ways: Codemode embeds a QuickJS sandbox in the agent loop so the model writes JavaScript to call registered tools instead of listing all definitions in context (measured 5300 → 3300 prompt tokens per turn); deferred tool loading brings tools in only when needed; PiDurable checkpoints agent state for resumable long tasks. Caveats: tools must be adapted to the JS mechanism, migration from JSON function-calling frameworks has costs, and weaker models may do better with structured function calling than writing JS.

Original post →

More from coding & agent

coding & agent channel →