TokenEconomizer: a Microsoft plugin for reducing token costs in coding agents
Microsoft Research and UC Berkeley released the open-source TokenEconomizer plugin, which learns from past sessions and reduces the cost of running coding agents by 18.4–30.9% on SWE-Bench without changing the agent's code.
On October 30, 2026, Microsoft Research and UC Berkeley presented TokenEconomizer — an open-source cost controller for coding agents. It is a plugin that learns from past sessions in a repository and cuts unnecessary spending in subsequent ones. It works with Claude Code, Codex, GitHub Copilot CLI and Pi. It does not touch the model weights or the agent's code.
Each agent turn re-pays for the system prompt, the schemas of loaded tools and the entire history. The researchers analyzed 60 SWE-Bench tasks in 6 repositories with Claude Code and Opus 4.8 and found three recurring sources of spending. The exact wording of these sources is cut off in the source text, so there is no data.
TokenEconomizer is an external controller that treats the agent as a black box. It stores per-repository state built from completed traces (traces — records of executed steps). Before each task it sets three policies: via the prompt, tool settings and the event stream.
An LLM proposer turns trace digests into one-line facts, for example a working command for tests. Each fact is equipped with regex detectors that check subsequent traces without calling the model. A fact enters the prompt after three confirmations on tasks with non-overlapping changed files. Its need rate must stay at or above 0.4. A single contradiction invalidates the fact, so erroneous facts are filtered out quickly.
The shell, read, write and edit tools are always kept. The rest are masked after three consecutive tasks where they were not used, or when an LLM judge deems them irrelevant. The full catalog is restored every five tasks for re-checking. On Django with Claude Code, the first request on the second task dropped from 43,351 to 16,295 prompt tokens.

On 277 SWE-Bench tasks, TokenEconomizer reduced average cost by 18.4–30.9% across five agent–model combinations. Three fixed open strategies were also tested: RTK, Serena and Aider's RepoMap. None was cheaper everywhere. Not all three reduced cost on Django and increased it on SymPy.
The main difference from alternatives is adaptivity. RTK, Serena and RepoMap apply fixed rules. TokenEconomizer, by contrast, accumulates facts about a specific repository and updates policies based on confirmations and contradictions. It requires no changes to the agent, which simplifies adoption. However, it does not replace tools like Serena: those can work out of the box, but without learning from traces.
Who it is not for: if you work with a single repository for only a short time, the learning effect may not have time to show. The plugin also will not help if the agent is already manually optimized or uses models with a fixed price per request that does not account for tokens. There is no data on support for agents other than those listed.
Bottom line: TokenEconomizer is a practical way to lower the token bill without rewriting the agent. It does not promise miracles, but in tests it shows a moderate reduction in costs. The solution is open source; the price is not disclosed — nor are the license terms in the source text.