TokenEconomizer: AI Coding Agent Reduces Costs by 30% Through Experience Learning Plugin

The open-source plugin TokenEconomizer, developed by Microsoft Research and UC Berkeley, has addressed the repetitive waste of AI coding agents through experience learning. In 277 real bug-fixing tasks, it successfully reduced costs by an average of 18.4% to 30.9% without modifying the agent or model while maintaining success rates. Three mechanisms—micro-skills, tool pruning, and failure-loop intervention—adaptively operate per repository, with cumulative costs falling below the default from the 6th task onward.

Hidden Costs of AI Coding Agents Arise from 'Lack of Experience'

Even if developers use AI coding agents daily in the same repository, the agent starts from scratch in each session. It rediscover familiar facts, loads tools that will not be used, and repeats failed approaches. The joint research team from Microsoft Research and UC Berkeley profiled 60 tasks from SWE-Bench sequentially by repository using Claude Code. As a result, three distinct waste patterns emerged.

Waste TypeKey FiguresDetails
Rediscovery of the Same Fact30% Repeated Tool CallsAfter accumulating over 5 tasks, previous actions are repeated within the same repository. Matches with other repository histories are only 7%
Loading Unused Tools16 out of 23 UncalledFull tool descriptions are provided every turn. Most tools, except for core ones, remain unused
Failure Loop Stagnation17% of Failures Account for 32% of CostsExcessive turns spent on attempts to fix the same error

The research team pointed out that "since developers return to the same repository, the agent has the opportunity to learn from previous work," and noted that fixed cost reduction strategies cannot resolve repository-specific variances.

TokenEconomizer: Experience Learning Through a Black Box Approach

TokenEconomizer operates as a plugin that does not modify the agent or underlying model. It reads session logs and updates repository knowledge, then activates three mechanisms using only the interfaces already provided by the agent.

"The controller is designed to modify decisions when new evidence arrives. The reported savings also include the costs of calling the TokenEconomizer model itself." — from the original text

Validation with 277 Real Tasks: Cost Reduction Across All Repositories and Combinations

Evaluated with 6 repositories from SWE-Bench, 5 agent-model combinations, and 277 bug-fixing tasks. TokenEconomizer reduced costs by an average of 18.4% to 30.9% across all 30 repository-combination pairs, while maintaining overall task success rates. Methods to reduce inference effort yielded similar savings but resulted in significant performance degradation.

SWE-Bench18.4-30.9%
Web-Bench16.0-21.2%
Security Audit6.4-19.6%

As experience accumulates, the extent of savings expands. Initial tasks may incur higher learning costs, but from the 6th task onward, cumulative costs fell below the default. Each of the three mechanisms contributes independently, achieving maximum effectiveness when combined. In sequential web development (Web-Bench), savings of 16.0% to 21.2% were confirmed, while in security audits where each task involved a new repository, savings of 6.4% to 19.6% were also observed.

Implications: Agents Learning 'Cost Knowledge' Beyond 'Task Knowledge'

TokenEconomizer enables agents to learn not only 'what they know' but also 'how to use it efficiently' through experience. Distributed as an open-source plugin, it can be immediately applied to existing workflows, requiring no separate API keys and reducing security concerns by storing local learning data. However, further validation is needed regarding the criteria for selecting judge models, tuning micro-skill thresholds, and scalability in large monorepos.

Verified figures

Our take

TokenEconomizer is a practical approach that achieves immediate cost reduction effects with just a plugin, without model replacement. Its adaptive learning by repository provides an advantage over fixed strategies, and the open-source release is expected to accelerate ecosystem expansion.

Open questions

Source

Back to catalog