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.
More from coding & agent
- Claude Code Pushes Urgent Security Update Across All Installations — umeshonai · 2026-10-23
- Claude cut a 2.6-hour video export to 20 minutes — but only after being told to rebuild the server — byhewar · 2026-10-23
- 3 flight-booking rules my AI agent checks that I'd never do by hand — Efistoffeles · 2026-10-23
- OpenJet claims Qwen3.8-27B coding runs 1.9x faster than llama.cpp on one RTX 3090 — JeremyCMorgan · 2026-10-23
- Building an autonomous SEO agent in Hermes with three skills: programmatic pages, Keywords Everywhere, DataForSEO — EXM7777 · 2026-10-23
- Building a sports betting AI agent with onchain execution and human approval by default: architecture and lessons — Dry-Comfortable-2678 · 2026-10-23