← News

AI coding

Microsoft and UC Berkeley Open-Source TokenEconomizer to Cut AI Coding Agent Costs by 18%–31%

Microsoft Research and UC Berkeley released TokenEconomizer, an open-source plugin that learns from past sessions in a repository to reduce AI coding agent costs by 18.4%–30.9% without changing the agent or model.

Published: 2026-11-18 11:11 UTCUpdated: 2026-11-18 11:11 UTCSource date: 2026-11-16

Researchers from Microsoft Research, Microsoft Security and UC Berkeley have released TokenEconomizer, an open-source plugin that lets AI coding agents learn from past sessions in the same repository so future tasks consume fewer tokens. The accompanying paper is titled "TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents."

The team first profiled Claude Code on 60 SWE-Bench tasks, a benchmark of real bug fixes in open-source Python projects, running each repository's tasks in sequence. Three kinds of waste recurred. First, rediscovery: once a repository had accumulated at least five completed tasks, 30% of tool calls repeated an action from an earlier task in that repository, while only 7% matched another repository's history. Second, paying for unused tools: the agent received 23 tool descriptions on every turn, but 16 were never called. Third, getting stuck: the 17% of tasks that failed accounted for 32% of spending. The team also tested three popular open-source plugins, each built around a fixed cost-saving strategy, and found each lowered costs in some repositories but not others, which the researchers say implies cost control must adapt to the repository.

After each session, TokenEconomizer reads the log and updates what it knows about the repository, then acts through three mechanisms using only interfaces the agent already provides. Micro-skills record repository-specific knowledge as one-line notes; patterns are added to the agent's starting context only after several sessions confirm them, and notes are retired if later evidence contradicts them. Tool pruning removes tools that repository history suggests the agent is unlikely to use, while always retaining core tools for running commands and editing files; removed tools can be restored. Failure-loop intervention watches for an agent repeatedly hitting the same failure, with a judge model deciding whether it is truly stuck or still progressing. If stuck, the agent gets a short note suggesting a different approach; if it remains stuck, the plugin alerts the developer rather than stopping the work itself.

Evaluation covered 277 SWE-Bench tasks from six repositories using five agent-and-model combinations, each repository starting with no prior history. According to the paper, TokenEconomizer lowered average cost by 18.4% to 30.9%, saving the most in all 30 repository-combination pairs without performance loss. By contrast, lowering the model's reasoning effort saved similar or larger amounts but led to substantial performance degradation. Pass@1 reportedly rose in four of the five combinations.

Savings grow as experience accumulates. Early tasks can cost more while the plugin learns, but the paper says cumulative costs fell below the default in every repository by the sixth task. Each mechanism contributes savings on its own, and combining all three delivers the largest reduction. The team reports savings carried over to sequential web development, with costs 16.0%–21.2% lower on Web-Bench, and to security auditing, where every task sits in a new repository, with costs 6.4%–19.6% lower.

From an engineering standpoint, the notable property is that the approach is black-box: it does not modify the agent or its underlying model, requires no API key of its own and keeps what it learns on the developer's machine, so it can run alongside agents developers already use. The reported figures, however, come from the researchers' own evaluation on SWE-Bench and Web-Bench; long-term behavior in real development environments remains to be tested by the community. The team invites developers and researchers to use the plugin as a starting point for agents that adapt how they spend computation, not just what they know.


Related articles