An open plugin makes coding agents cheaper the longer they work in a project
TokenEconomizer, from UC Berkeley, Microsoft Research and Microsoft Security, learns from a coding agent's finished sessions in a repository. On 277 SWE-Bench tasks it lowered the mean cost per task by 18.4 to 30.9% across five combinations of agent and model. Microsoft Research described it on 16 November; the paper was submitted on 15 October.

In each session a coding agent sends its instructions, the descriptions of its tools and the history of the session to its model, and every one of those tokens is billed. To see where the money goes, the team profiled 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. Three kinds of waste recurred. Once a repository had at least five completed tasks, 30% of tool calls repeated an action from an earlier task in that repository, while only 7% matched an action in another repository's history. The agent received 23 tool descriptions on every turn, and 16 were never called. The 17% of tasks that failed accounted for 32% of the spending.
The team also tried three popular open-source plugins, each built around one fixed way of saving cost. Each lowered costs in some repositories but not in others, which the authors read as a sign that cost control has to adapt to the repository.
TokenEconomizer has three mechanisms. The first, micro-skills, keeps one-line notes on how the repository works: a build step that must run first, the spelling of the test command that works here, an environment variable a command needs. The notes come from failures that repeat across sessions and from a model that reviews recent sessions every three sessions. A fact is stated at the start of each session once three sessions have confirmed it, and it is dropped when later sessions contradict it.
The second, tool pruning, stops loading tools that go unused. By default a tool that is not used over 10 prompts spread across at least two sessions, or over five sessions of any length, is left out of the next sessions through the agent's own settings. The core tools for running commands and editing files are always kept, and one command brings a removed tool back.
The third watches for a turn that keeps hitting the same failures. A judge model checks whether the agent is stuck, and if it is at least 0.7 sure, the agent gets a short note suggesting another approach, at most once per turn. If the turn is still stuck after that, the plugin tells the developer how to stop it. It never stops a turn itself.
The evaluation used 277 SWE-Bench tasks from six repositories and five combinations of agent and model across Claude Code, Codex and GitHub Copilot CLI, starting each repository with no history. The mean cost per task fell by 18.4 to 30.9%, counting the plugin's own model calls, and costs fell in all 30 pairs of repository and combination. Pass@1, the share of tasks solved at the first attempt, rose in four of the five combinations. Lowering the model's reasoning effort saved similar or larger amounts but led to substantial performance degradation.
Savings grow with experience. Early tasks can cost more while the plugin learns, but with Claude Code the cumulative cost fell below the default in every repository by the sixth task. The savings carried over to sequential web development, with costs 16.0 to 21.2% lower on Web-Bench, and to security auditing, where every task is in a new repository, with costs 6.4 to 19.6% lower.
The plugin supports Claude Code, Codex, the GitHub Copilot CLI and Pi, with experimental support for opencode, Cursor Agent, Grok Build, Hermes Agent, the Antigravity CLI and Factory Droid. Each mechanism can be switched on or off. Its model calls run through the developer's own agent, on the same plan or login, and what it learns stays in a folder on the developer's machine.
