AivexaNewsSearch
AI news for builders and product teamsChecked every hour

TokenEconomizer: Learning from Experience to Make AI Coding Agents More Efficient

Collected Nov 16, 2026

Microsoft Research, working with UC Berkeley and Microsoft Security, has released TokenEconomizer, an open-source plugin that learns from a coding agent's earlier sessions in a repository in order to make later sessions cheaper. The work is described in a paper titled TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents. The plugin sits alongside an existing coding agent and does not alter the agent or the model behind it, so teams can keep the tools they already use.

The motivation comes from a profile of Claude Code on 60 SWE-Bench tasks, a benchmark of real bug fixes in open-source Python projects, with each repository's tasks run in sequence. Three forms of waste showed up repeatedly. Once a repository had at least five completed tasks, 30% of tool calls repeated an action from an earlier task in that same repository, while only 7% matched an action from another repository's history. The agent was handed 23 tool descriptions on every turn, and 16 of those tools were never called. And the 17% of tasks that failed consumed 32% of total spending. The team also tested three popular open-source plugins built around fixed cost-saving strategies; each reduced costs in some repositories but not others, which the authors read as evidence that cost control has to adapt to the repository rather than apply one policy everywhere.

After each session, TokenEconomizer reads the session log and updates its picture of the repository. It then acts through three mechanisms, all using interfaces the agent already exposes. Micro-skills are one-line notes capturing repository-specific knowledge; the system spots recurring patterns across sessions and proposes notes, but only adds a note to the agent's starting context after several sessions confirm the pattern, and retires it if later evidence contradicts it. Tool pruning drops tools that repository history suggests are unlikely to be used, while always keeping the core tools for running commands and editing files; removed tools can be brought back if needed. Failure-loop intervention watches for an agent hitting the same failure repeatedly. A judge model decides whether the agent is genuinely stuck or still making progress, and if it is stuck the agent receives a short note suggesting a different approach. If the agent remains stuck after that note, the open-source plugin alerts the developer rather than halting the work itself. The controller is built to revise its decisions as new evidence arrives, and the reported savings account for the model calls TokenEconomizer makes on its own.

The evaluation covered 277 SWE-Bench tasks drawn from six repositories, run across five different agent-and-model combinations, with each repository starting from no prior session history. Average cost per task fell by 18.4–30.9%, and TokenEconomizer was the biggest saver in all 30 repository–combination pairs without a loss in performance. Pass@1, the share of tasks solved on the first attempt, rose in four of the five combinations. The comparison the authors highlight is with simply lowering the model's reasoning effort: that saved similar or larger amounts but caused substantial performance degradation. Savings also grow with experience. Early tasks can cost more while the system learns, but cumulative cost dropped below the default in every repository by the sixth task. Each mechanism contributes savings on its own, and running all three together gives the largest reduction.

The approach also transferred beyond bug fixing. On sequential web development tasks in Web-Bench, costs came out 16.0–21.2% lower. On security auditing, where every task sits in a new repository, costs were still 6.4–19.6% lower. That last result is notable because micro-skills and tool pruning draw on repository history; it suggests the failure-loop intervention and whatever general behavior the controller learns carry some of the load even without accumulated per-repository experience.

This is best understood as a black-box cost-control layer. Because everything flows through interfaces the agent already provides (context, tool lists and steering notes) rather than through weights or fine-tuning, it should apply across vendors and model versions. The trade-off is that its leverage is indirect. Micro-skills are only one-line notes and depend on repeated confirmation before they appear, so a repository may need several sessions before the savings offset the early overhead. Tool pruning is heuristic, and a restored tool may itself cost extra turns. The judge model adds its own latency and cost, which the reported figures include. The plugin requires no API key of its own and keeps what it learns on the developer's machine, which matters for teams that cannot ship repository context to a third-party service.

Why it matters: teams running agents repeatedly against the same codebases are the clearest beneficiaries, since the savings compound with every completed session in a repository. For developers, the headline is that agent cost can be treated as something to manage at the workflow level, not just per prompt, and that a plugin can do this without swapping models. In practice, a likely trade-off for adopters is slower early sessions in exchange for cheaper ones later, which fits long-lived internal repositories better than one-off or heavily unfamiliar codebases.

Read at Microsoft Research

Based on reporting from the original publisher. Visit the source for full context and later updates.

Publisher excerpt

AI coding agents can waste time and tokens relearning the same lessons. TokenEconomizer is an open-source plugin that builds on past sessions to cut costs while maintaining task success. It’s a path toward coding agents that learn not only how to solve tasks, but also how to spend computation more effectively. The post TokenEconomizer: Learning from Experience to Make AI Coding Agents More Efficient appeared first on Microsoft Research .