// AI & AUTONOMY

TokenEconomizer cuts AI coding agent costs by up to 30.9%

Microsoft and UC Berkeley built an open-source plugin that learns from past coding sessions to cut token waste while keeping bug-fix success rates stable.

Nov 16, 2026 · 20:49  /  Source: microsoft.com

AIXVZ

AI agents that sell for you. AIXVZ builds sales agents and automates routine business processes — from first contact to deal.

Learn more
TokenEconomizer cuts AI coding agent costs by up to 30.9%

Researchers from UC Berkeley, Microsoft Research and Microsoft Security built TokenEconomizer, an open-source plugin that learns from an AI coding agent's past work in a repository to cut token waste. Across 277 real bug-fixing tasks, it reduced average costs by 18.4-30.9% across five agent and model combinations, with costs falling in every repository tested while success rates remained broadly stable.

Repeated work, unused tools and failure loops

TokenEconomizer targets waste that recurs when developers use agents in the same codebase day after day. Profiling Claude Code on 60 tasks from SWE-Bench, a benchmark of real bug fixes in open-source Python projects, found that after five completed tasks in a repository, 30% of tool calls repeated an action from an earlier task there, versus 7% matching another repository's history. The agent received 23 tool descriptions on every turn, but 16 were never called, and the 17% of tasks that failed accounted for 32% of spending.

The team also tested three popular open-source plugins built around fixed cost-saving strategies. Each lowered costs in some repositories but not others, suggesting cost control must adapt to the repository rather than apply one strategy everywhere. TokenEconomizer works without modifying the agent or its underlying model, using only interfaces the agent already provides. Reported savings include the cost of its own model calls, and what it learns stays on the developer's machine with no separate API key required.

How the plugin saves tokens in practice

After each session, TokenEconomizer reads the session log and updates repository knowledge through three mechanisms. Micro-skills store recurring repository-specific facts as one-line notes, added to starting context only after several sessions confirm a pattern and retired if later evidence contradicts it. Tool pruning removes tools history suggests are unlikely to be used, while keeping core tools for commands and file edits, with removed tools restorable. Failure-loop intervention uses a judge model to detect repeated failures and suggests a different approach, alerting the developer if the agent remains stuck.

Savings grow as experience accumulates, with cumulative costs falling below the default in every repository by the sixth task, although early tasks can cost more while the system learns. Each mechanism saves on its own, and the combination delivers the largest reduction. The approach also carried over to sequential web development on Web-Bench, with costs 16.0-21.2% lower, and to security auditing in new repositories, with costs 6.4-19.6% lower. By contrast, lowering model reasoning effort saved similar or larger amounts but caused substantial performance degradation.

Share

// Read next