TokenEconomizer: A Microsoft Plugin Cuts Coding Agent Costs by 30.9 Percent
By Indie Kings | October 31, 2026
Updated October 31, 2026: TokenEconomizer is a Microsoft plugin that makes coding agents cheaper by learning how a repository works instead of changing the model. Its first release, v0.1.0, arrived on October 26, 2026, with a paper reporting 18.4 percent to 30.9 percent lower mean cost across five agent and model combinations on 277 SWE-Bench tasks.
Image: TokenEconomizer teaser showing its three mechanisms and supported agents, from the project repository.
Three mechanisms, one bet
The bet is simple. Coding agents are built to finish a task, not to stay cheap. Every request pays again for the agent's instructions, every loaded tool and the conversation so far. Developers use the same agent on the same repository for months, so much of that cost repeats: the same facts rediscovered, the same unused tools sent, the same failing turns repeated.
TokenEconomizer is a plugin for Claude Code, Codex, the GitHub Copilot CLI and Pi, with experimental support for opencode. It leaves the model, the weights and the agent's code alone. It reads finished sessions in a repository and changes what the next sessions start with. The project calls this black-box cost control because it works through logs, settings and context rather than through retraining.
The first mechanism is micro-skills. Sessions keep rediscovering the same repository facts: a build step that must run first, the spelling of a command that works here, an environment variable a command needs, where generated files live. Micro-skills learns those facts from two sources: failures that repeat across sessions, and a model that reviews recent sessions every three sessions and proposes facts. A fact is stated at the start of each session once three sessions have confirmed it, and dropped when later sessions contradict it. Micro-skills is off by default because its proposer adds model calls.
The second mechanism is tool pruning. Every loaded tool's definition is sent with every request, whether the agent uses it or not. A tool that goes unused over 10 prompts spread across at least two sessions, or over five sessions of any length, is left out of later sessions through the agent's own settings. One command brings it back. The plugin writes only its own entries, never touches deny rules the user wrote, and keeps a settings file it creates out of git.
Tool pruning looks different on each agent because each agent exposes a different unit. On Claude Code it removes single tools and writes to .claude/settings.local.json. On Codex it removes capability packages and writes to .codex/config.toml. On the Copilot CLI it removes whole MCP servers and writes to .github/copilot/settings.local.json. On Pi and opencode it removes nothing yet, because Pi loads only four tools and opencode support is experimental.
The third mechanism is failure-loop intervention, also called the loop guard. When a turn keeps hitting the same failures, a judge model checks whether the agent is stuck. If the judge is at least 0.7 sure, the agent gets a short redirect in its context telling it to try another approach, at most once per turn. If the turn is still stuck after that, the plugin tells the user how to stop it. It never stops a turn itself. A backstop can redirect a turn that runs past 2.5 times the usual length while churning the same edits through the same failures.
All of this stays local. What the plugin learns lives in a folder under the user's home directory, and its model calls run through the user's own agent, on the same plan or login. The plugin needs no API key of its own and never handles credentials. Its own model calls are included in the cost reports, which matters for the numbers in the next section.
The savings, and the one number that went down
The paper ran five agent and model combinations on the same 277 SWE-Bench tasks from six repositories. Each task ran as its own session, and each repository's tasks ran in order, starting with nothing learned. That setup is important. It measures a plugin that gets better as it sees more of a repository, not a plugin that arrives preloaded with knowledge.
Across those runs, mean cost fell by 18.4 percent to 30.9 percent. The plugin was cheaper than the default in all 30 repository and combination cells. Pass@1 rose in four of the five combinations. The exception is the combination with the largest cost cut: Claude Code with Opus 4.8 saved 30.9 percent but lost 1.0 point of Pass@1. A cheaper agent that solves slightly fewer tasks is not a free win.
The per-combination numbers are worth reading together. Claude Code with Sonnet 5 cut cost by 23.6 percent and gained 1.3 points of Pass@1. Codex with GPT-5.6 Terra cut cost by 24.7 percent and gained 0.9. Codex with GPT-5.6 Sol cut cost by 26.1 percent and gained 1.6. The Copilot CLI with Sonnet 5 cut cost by 18.4 percent and gained 2.6. Those gains are not enormous, but they are measured on the same task set rather than on a vendor demo.
The paper also reports savings outside the headline benchmark. On Web-Bench, cost fell by 16 percent to 21 percent. On two security-auditing benchmarks where every task is in a new repository, cost fell by 6 percent to 20 percent. That last result is the interesting one for the mechanism: tool pruning and the loop guard can help even when the plugin has no repository history to learn from, while micro-skills needs repeat visits.
Within each repository and combination, cost fell by 5 percent to 40 percent. The headline range is a mean across tasks, so a single repository can land near the low end. The practical lesson is that the first sessions teach the plugin and the savings arrive later. A developer who tries it on a one-off repository should not expect the published average.
These are the project's own measurements, published with the code and an arXiv paper. They are not an independent lab test. The paper lists its harness and task sets in the experiments folder, which lets a skeptical reader rerun the work, but rerunning it is a project of its own.
Who should install it, and who should wait
The best fit is a developer who uses one of the supported agents in the same repository most days. That is the case the plugin was designed around, and the case where micro-skills has enough sessions to learn from. A team that switches repositories every week will see less benefit and may see more of the plugin's own overhead.
Installation is deliberately close to the agent's normal plugin flow. Claude Code users add the cloned repository as a marketplace and install the plugin. Codex and the Copilot CLI have their own marketplace commands. Pi installs from a git URL. opencode users symlink a TypeScript plugin into their config directory and run the status command from a terminal. Python 3.10 or newer must be on the path, and Claude Code, Codex and the Copilot CLI run the plugin from the clone, so the folder has to stay in place.
The supported version ranges are narrow. Claude Code 2.1.300 to 2.1.310, Codex 0.153.1 to 0.164.0, Copilot CLI 1.0.83 to 1.0.102, and Pi 1.2.0 to 1.3.0. The README says the commands were tested on the oldest and newest version in each range and that newer versions have not been tested. opencode support was tested on 1.19.5 and 2.2.0 only, and not in the 2.x terminal interface.
The defaults are conservative in one direction and aggressive in another. Tool pruning and the loop guard are on, so the plugin edits agent settings and can call a judge model when a turn looks stuck. Micro-skills is off, so the plugin does not spend model calls proposing repository facts until the user turns it on. A user who wants micro-skills without its proposer can set it to envfacts mode, which learns only from repeated failures.
There are escape hatches. Setting TE_DISABLE=1 turns the whole plugin off for a session. TE_LOOPGUARD=off, TE_MICROSKILLS=off and TE_TOOLPRUNE=off disable one mechanism at a time. Tool pruning has a propose mode that only suggests a deny list, and a restore command that gives tools back and stops them from being removed again. If the plugin cannot edit a settings file safely, the list stays a proposal and the session start says why.
The reasons to wait are the usual ones for an 18-day-old project. The repository had seven open issues at the time of writing, which is low for its age but not zero. Tool pruning can remove a tool that a later, unusual task needs, and the restore path is a command the user has to know about. The loop guard's judge is another model call, so a stuck turn costs more before it gets help. And the savings depend on repeated work in one repository, which is exactly the kind of workload the paper measured.
The plugin is also honest about failure. If any part of it fails, the session carries on as if it were not installed. That is the right default for a tool that sits between a developer and an agent, but it also means a silent failure looks like a session with no savings. The status command is the way to check what it learned and what it did.
Measured on SWE-Bench
| Measure | Result |
|---|---|
| Tasks and repositories | 277 SWE-Bench tasks from six repositories |
| Agent and model combinations | Five |
| Mean cost change | 18.4 to 30.9 percent lower |
| Repository and combination cells cheaper | 30 of 30 |
| Pass@1 improved | 4 of 5 combinations |
| Per-repository cost change | 5 to 40 percent lower |
| Web-Bench cost change | 16 to 21 percent lower |
| Security-auditing benchmarks | 6 to 20 percent lower |
| Plugin data location | Local folder under the user's home directory |
| License | Apache 2.0 |
FAQ
What is TokenEconomizer?
A plugin for Claude Code, Codex, the Copilot CLI and Pi that learns from finished sessions in a repository and cuts repeated cost in later sessions. It does not change the model or the agent's code.
Which agents does it support?
Claude Code 2.1.300 to 2.1.310, Codex 0.153.1 to 0.164.0, Copilot CLI 1.0.83 to 1.0.102, and Pi 1.2.0 to 1.3.0. opencode support is experimental and was tested on 1.19.5 and 2.2.0 only.
How much does it save?
The paper reports 18.4 percent to 30.9 percent lower mean cost across five agent and model combinations on 277 SWE-Bench tasks, cheaper in all 30 repository and combination cells, with Pass@1 up in four of five. Those are the project's measurements, not an independent test.
Does it send my code to a server?
The plugin keeps what it learns on the local machine and needs no API key of its own. Its model calls run through the user's existing agent plan or login. The repository says it never handles credentials.
Why is micro-skills off by default?
Its fact proposer adds model calls, and the savings depend on the repository and the work a developer does there. Tool pruning and the loop guard are on by default because they do not need the proposer.
Can it break my agent session?
It is designed to fail open, so a plugin failure leaves the session running as if it were not installed. Tool pruning edits local settings and can be restored, and the loop guard never stops a turn itself. The project is young, so test it on a noncritical repository first.
Bottom Line
TokenEconomizer is a Microsoft Research plugin that attacks a real waste stream in coding agents: the same repository knowledge, the same unused tool definitions and the same failure loops paid for again and again. Its first release supports Claude Code, Codex, the Copilot CLI and Pi, keeps its data local, and reports 18.4 percent to 30.9 percent lower mean cost on 277 SWE-Bench tasks. It is cheaper in all 30 repository and combination cells, but Pass@1 fell in one of the five combinations.
Our take: the tool is most interesting as a measurement project. The mechanisms are simple enough to explain in a paragraph, and the paper publishes the harness, so the claims can be checked. The right first test is a repository you already use every day, with micro-skills off and tool pruning in propose mode, so you can see the suggested deny list before the plugin edits anything.
Sources
- GitHub microsoft/TokenEconomizer README, mechanisms, settings, supported versions, installation and results, accessed October 31, 2026
- GitHub release v0.1.0, first release notes and install commands, published October 26, 2026
- arXiv 2610.22732, TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents, by Aaron J. Li and coauthors
- GitHub API metadata for microsoft/TokenEconomizer, stars, forks, issues, creation date and license, accessed October 31, 2026
Related: Claude-Mem: Persistent Memory for Coding Agents at 105k Stars | NVIDIA: 415 Signed Agent Skills Now Ship for Claude Code and Codex | Universal Modder Gives AI Agents A Safe Modding Playbook