TokenEconomizer is a cost-control layer for coding agents: a Python project from UC Berkeley, Microsoft Research and Microsoft Security that learns from the sessions you have already run in a repository and uses that experience to make the next session cheaper. It is aimed at developers who run Claude Code, Codex or GitHub Copilot CLI against the same codebase every day and have noticed how much of each session goes into rediscovering things the agent already worked out last week.
What it does
A coding agent starts every session with no memory of the previous one. It hunts for the test command again, reads the same handful of files again, and carries a full catalog of tool definitions whether or not this particular project ever uses them. TokenEconomizer attacks that from three directions:
- Micro-skills: small remembered facts harvested from earlier sessions in the same repository, such as the test command that actually works here.
- Tool pruning: it stops sending tool definitions for tools this repository never touches.
- Failure-loop intervention: when a turn keeps repeating the same failure, a judge model steps in and redirects the agent to try another approach.
The approach is black-box, which means it wraps an agent you already use instead of requiring a patched or purpose-built one. The README names Claude Code, Codex, GitHub Copilot CLI and Pi.
The headline figure comes from the authors themselves. Their measurement on SWE-Bench tasks reports 18.4 to 30.9 percent lower mean cost across five agent and model combinations, cheaper in all 30 repository-by-combination cells, and Pass@1 up in four of the five. That is the paper's own benchmark rather than an independent replication, and nobody on this channel has rerun it.
How it works
Experience-driven is the operative word: the raw material is your own session history in a given repository, not a generic prompt library. The savings come from spending fewer tokens on things the agent has already learned somewhere in that history, and from not shipping context the project has no use for.
Two details matter before you judge the results. Micro-skills ships switched off by default, so you have to enable it yourself rather than assume it is working. And the failure-loop judge is itself a model call: an extra inference request layered on top of your agent's normal traffic, which you pay for like any other call.
Getting started
The badges put the floor at Python 3.10 or newer, and the licence is Apache 2.0. The project does not list hardware requirements, so treat it as an ordinary Python tool rather than something that needs a GPU.
What it does not do is supply any intelligence of its own. TokenEconomizer is free and open source, but it sits in front of a coding agent whose model you already pay for, whether that is a subscription or an API key, and the judge model adds calls to that bill. The claim here is a smaller bill for the same work, not a free setup.
The code lives at github.com/microsoft/TokenEconomizer. The saved materials do not include an install command, so take the exact steps from the repository's README rather than from this page. There is also a paper (arXiv 2610.22732) and a project page at tokeneconomizer.github.io if you want the methodology before the install. Worth knowing the project is young: created in October 2026 and still being pushed to in November 2026, with roughly 4,900 stars and 300 forks already.
When to use it / when not
The main catch is in the failure-loop feature: it never stops a stuck turn on its own, it only tells the agent how to get unstuck. If you were hoping for a circuit breaker that kills a runaway session before it burns another dollar, this is not that. Combine that with micro-skills being off by default and an age measured in weeks, and you should expect to spend some time configuring and watching it rather than installing it and forgetting about it.
Use it instead of hand-curating per-repository context when you want those facts and tool lists derived from sessions that actually happened rather than from your own guesses about what the agent needs. Don't use it if you work across many repositories in single short sessions, since there is no accumulated session history for it to learn from, or if your spend is already dominated by one long interactive session rather than by repeated cold starts.
Take this one seriously if you are paying real money for agent sessions on a stable codebase, because that is exactly the shape of workload its three mechanisms are built for, and the authors have published both the code and the benchmark behind their claim. Treat it with more caution if you want a finished product: this is paper-accompanying research code from a Microsoft and Berkeley team, with a default-off flag and a deliberately advisory stance toward stuck agents. The measurement is theirs, the configuration is yours, and the honest test is whether your own bills drop on your own repository.