Microsoft Research and UC Berkeley released TokenEconomizer, an open-source Apache 2.0 plugin that reduces coding agent costs by learning per-repository policies from completed traces, compatible with Claude Code, Codex, GitHub Copilot CLI, and Pi on Python 3.10+ without GPU or dedicated API keys. Evaluated on 277 SWE-Bench tasks across five agent-model settings, it lowered mean cost by 18.4% to 30.9% and was cheaper in all 30 repository-setting cells, peaking at 30.9% savings on Claude Code with Opus 4.8 (33.2% combined with RTK). Pass@1 improved in four of five settings but dropped 1.0 point on Opus 4.8. The controller operates via three mechanisms: micro-skills, which distill trace digests into regex-backed facts promoted after three confirmations on non-overlapping files with a need rate ≥0.4; tool pruning, which masks unused tools after three consecutive idle tasks or LLM judge irrelevance, restoring the full catalog every five tasks for re-audit (reducing first-request prompt tokens on Django from 43,351 to 16,295); and failure-loop intervention, which sets a turn budget at 1.25× the 90th percentile of successful run lengths, using cheap rule checks and an LLM judge (≥0.7 confidence) to issue one redirect then stop on recurrence. Ablation showed tool pruning saved 13.2%–17.7%, micro-skills 11.8%–14.3%, and loop guard 5.4%–7.1%. Savings accumulated over tasks, with all repositories cheaper by task six. Results generalized to Web-Bench (16.0%–21.2%) and CredData (16.5%–19.6%), but ReposVul saw only 6.4%–9.3% due to shorter runs. Unlike fixed strategies (RTK, Serena, Aider RepoMap), which raised costs in 12 and 15 of 30 cells respectively, TokenEconomizer consistently reduced spend.
Read original
marktechpost