TokenEconomizer learns from past work to cut AI coding costs by up to 30.9%
An open-source plugin lets coding assistants remember what they learned in one project, so future tasks cost less and still succeed.

An open-source plugin that lets AI coding assistants remember past work, so future tasks cost fewer tokens.
- Install the plugin alongside your AI coding agent.
- Use the agent to complete tasks in your repository.
- It records patterns, trims unused tools, and spots failures.
- Future tasks in that repo use fewer tokens and succeed.
In short
What happened: TokenEconomizer is an open-source plugin developed by UC Berkeley, Microsoft Research, and Microsoft Security. This tool converts completed coding sessions into summaries so the same assistant can process future work on that project more quickly and at lower cost.
- Why it matters: Developers who use AI coding agents day after day often see those agents repeat themselves, reload unused tools and retry mistakes — wasting money on every prompt. TokenEconomizer cuts that waste without changing the agent or the model behind it, saving roughly one-fifth to nearly a third of costs in tests while keeping success rates steady.
- Words to know: Token: a unit of text an AI model reads or writes; models charge by the token. Agent: a program that can call tools — run commands, edit files, search code — mostly on its own.
What you could do with it
- A developer using Claude Code or another AI coding agent could install the open-source TokenEconomizer plugin so repeated bug-fixing tasks in their repository cost less tokens over time 1.
- A team doing sequential web development work could run TokenEconomizer alongside their existing agent to drop task costs by 16.0–21.2 percent compared with running the agent without it 1.
- A developer who receives many prompts in new repositories could still benefit, seeing costs fall by 6.4–19.6 percent even when there is no prior session history to draw on 1.

Picture: microsoft.com
Where the waste happens
Researchers first profiled how Claude Code from Anthropic spends tokens on real bug-fixing tasks drawn from SWE-Bench, a benchmark built from actual issues in open-source Python projects 1. Three patterns kept coming back .
First, the agent rediscovered the same facts over and over. After a repository had seen at least five completed tasks, 30 percent of tool calls repeated something done earlier in that same repo — and only 7 percent matched an action from a different project's history 1. Second, the agent paid to load tool descriptions it never used. It received 23 tool definitions every turn but called only a fraction of them, leaving 16 unused . Third, failed tasks ate disproportionate spending.
The team also ran three existing open-source cost-cutting plugins. Each helped in some repositories but not others, suggesting no single fixed strategy works everywhere 1.
How much AI coding costs drop when agents remember past work
Tests across six GitHub repos, five agent-model pairs, on SWE-Bench, Web-Bench, and security-auditing tasks
How it learns and saves
TokenEconomizer sits alongside the unchanged coding agent and updates what it knows after every session by reading the session log 1. It uses three mechanisms built on interfaces the agent already provides .
Micro-skills record repository-specific patterns as one-line notes. A note appears only after several sessions confirm the pattern, and it is removed later if new evidence contradicts it 1. Tool pruning drops tool descriptions that the repository's history shows the agent rarely needs, while always keeping core command and file-editing tools; pruned tools can be restored if necessary . Failure-loop intervention steps in when the agent repeats the same mistake. A separate judge model checks whether the agent is truly stuck or still progressing, and if it is stuck the agent gets a short note suggesting another route . If the agent remains stuck after that note, the plugin alerts the developer instead of stopping the work on its own .
All reported savings include the small cost of TokenEconomizer's own model calls 1.
Savings with no drop in performance
The researchers tested TokenEconomizer on 277 SWE-Bench tasks spread across six repositories, running five different coding-agent and model combinations 1. Each repository started with no prior history .
Across the board, average cost per task fell by 18.4 to 30.9 percent, and every one of the 30 repository-combination pairs saw a reduction with no loss in performance 1. When researchers tried to save money simply by lowering the model's reasoning effort instead, they got similar or larger cuts but suffered substantial drops in how often tasks succeeded . By contrast, Pass@1 — the share of tasks solved correctly on the first try — rose in four of the five agent-model combinations .
Savings grew as the plugin accumulated experience. Early tasks could actually cost more while TokenEconomizer was still learning, but cumulative spending dropped below the default in every repository by the sixth task 1. Micro-skills, tool pruning and failure-loop intervention each contributed savings on their own, and combining all three produced the largest reduction .
The same approach also lowered costs on sequential web-development tasks by 16.0 to 21.2 percent on Web-Bench, and even in security auditing, where each task uses a fresh repository, costs fell by 6.4 to 19.6 percent 1.

Picture: microsoft.com

Picture: microsoft.com

Picture: microsoft.com
Key facts
- TokenEconomizer cut average task costs by 18.4–30.9% across 277 bug-fixing tasks and five agent-model combinations.
- Task success rates stayed broadly stable, and Pass@1 improved in four of five setups.
- The plugin starts helping from the sixth task onward in each repository, with cumulative savings rising as it learns.
- Savings extended beyond bug fixes: 16.0–21.2% lower costs on web development and 6.4–19.6% on security auditing.
- It works without modifying the agent or its underlying model, using micro-skills, tool pruning and failure-loop intervention.
Sources
If this story concerns you or your company, or uses something that belongs to you, ask for a correction or for it to be taken down. How requests work
Keep reading
The weekThis Week in AI New Models Flood In and Agents Get SaferHerald of AI
This Week in AI New Models Flood In and Agents Get Safer
Big open-weight releases, speed breakthroughs, and a push to make AI agents more reliable and secure.
Apps and productsJ.Crew launches an AI stylist powered by Anthropic's Claude modelsHerald of AI
J.Crew launches an AI stylist powered by Anthropic's Claude models
Shoppers in the US can now describe an occasion and get a full outfit from J.Crew — all using Claude instead of hunting for each piece one by one.
Business and rulesMirendil raises $1 billion to use AI agents for faster model developmentHerald of AI
Mirendil raises $1 billion to use AI agents for faster model development
A new startup founded by former Google DeepMind and Anthropic researchers says its automated platform lets small teams build large AI models quickly and cheaply.