Microsoft Research and UC Berkeley open-source TokenEconomizer, which lets coding agents remember lessons from the same repository and cut costs by 18.4% to 30.9% on 277 SWE-Bench tasks

1 views

Microsoft Research on November 16 introduced TokenEconomizer, an open-source plugin built with UC Berkeley and Microsoft Security. Without modifying the agent or model, it distills repository lessons from past sessions on the local machine, prunes unused tools and nudges agents out of failure loops. On 277 SWE-Bench bug-fixing tasks from six repositories, five agent-model combinations saw average cost reductions of 18.4% to 30.9% with broadly stable success rates. Because it starts with no history, early tasks can cost more; cumulative costs fell below the default in every repository by the sixth task.

Where the tokens go

The team first profiled 60 SWE-Bench tasks with Claude Code. After five or more completed tasks in a repository, 30% of tool calls repeated an earlier action there; each turn loaded 23 tool descriptions, 16 of which were never called; and failed tasks were 17% of the total but 32% of spending. TokenEconomizer targets those three kinds of waste.

Three mechanisms

The first is micro-skills: one-line, repository-specific notes distilled from finished sessions. A pattern must hold across several sessions before it enters the starting context, and it is retired if later evidence contradicts it. The second is tool pruning, which removes tools repository history suggests will go unused while always keeping core tools for running commands and editing files; removed tools can be restored. The third is failure-loop intervention: when repeated failures appear, a judge model decides whether the agent is stuck, a short note suggests a different approach, and if it stays stuck the developer is alerted rather than the work being stopped. The plugin needs no API key of its own and keeps what it learns on the developer's machine.

Savings arrive with continued use

On 277 SWE-Bench bug-fixing tasks from six repositories, the five agent-model combinations cut average costs by 18.4% to 30.9%, net of the plugin's own model calls, and pass@1 rose for four of them. Lowering reasoning effort saved similar or larger amounts but hurt success rates substantially. The cost is a cold start: early tasks can be more expensive, and cumulative costs fell below the default in every repository only by the sixth task. In security auditing, where each task uses a new repository, savings shrank to 6.4% to 19.6%. The post does not name the repositories or the combinations.

via: Microsoft Research Blog: TokenEconomizer, TokenEconomizer repository