Where the tokens go
Microsoft Research describes a problem: developers work for days in the same repositories, but coding agents start every session from scratch. In each session the agent sends the model instructions, tool descriptions and history, and all of this costs tokens. The paper is titled TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents, and the plugin comes from UC Berkeley, Microsoft Research and Microsoft Security.
For the diagnosis, the team measured the behavior of Claude Code on 60 tasks from SWE-Bench, a benchmark of real bug fixes in open-source Python projects, running each repository's tasks in sequence. It identified three recurring sources of waste. First, rediscovery of known information: once a repository had accumulated at least five completed tasks, 30% of tool calls repeated an action from a previous task in the same repository, and only 7% matched an action from another repository.
Second, unused tools: the agent received 23 tool descriptions in every turn and 16 of them were never called. Third, failures: the 17% of tasks that failed accounted for 32% of spending. The team also tested three popular open-source plugins with a fixed saving strategy. Each reduced cost in some repositories and not in others, and Microsoft Research concludes that cost control must adapt to the repository.
How the plugin works
After each session, TokenEconomizer reads the log and updates what it knows about the repository. It acts through three mechanisms, using only interfaces the agent already provides.
Micro-skills are one-line notes with repository-specific knowledge. They are added to the agent's initial context only after several sessions confirm the pattern, and are retired if newer evidence contradicts it. Tool pruning removes tools that the history shows are unlikely to be used, always keeping the essentials for running commands and editing files; removed tools can be restored.
Failure-loop intervention monitors whether the agent repeatedly falls into the same failure. A judge model decides whether the agent is genuinely stuck or making progress. If it is stuck, it receives a short note suggesting a different approach. In the open-source version, if it remains stuck, the plugin alerts the developer rather than halting the work on its own. Microsoft Research states that the cost of its own model calls is included in the reported savings.
Results and limits
The evaluation covered 277 SWE-Bench tasks from six repositories, with five combinations of coding agent and model. In each repository the plugin started with no history. Average cost per task fell by 18.4–30.9%, with savings in all 30 repository–combination pairs and no loss in performance. According to the paper, Pass@1 increased in four of the five combinations. Reducing the model's reasoning effort saved similar or larger amounts, but with a substantial degradation in performance.
Savings grow as experience accumulates. The first tasks may cost more while the system learns, but cumulative cost fell below the default in every repository by the sixth task (measured with Claude Code). Each mechanism contributes on its own, and combining all three yields the largest reduction.
The benefits also appeared outside SWE-Bench: 16.0–21.2% lower cost on Web-Bench, which involves sequential web development, and 6.4–19.6% on the security check, where each task takes place in a new repository. The figures come from the authors themselves and not from an independent evaluation.
Availability and next steps
The open-source plugin is designed to run alongside existing coding agents without modifying their models. It does not require its own API key and keeps what it learns on the developer's machine. Microsoft Research presents it as a starting point for agents that adapt how they work based on experience, and invites the community to build on it.