Why this matters now
Coding agent bills grow quietly. Every turn re-sends the system prompt, every loaded tool definition and the conversation so far, so a long session on one repository pays for the same material again and again. The TokenEconomizer paper (arXiv 2610.22732, published 15 October 2026) measured this waste directly. On 60 SWE-Bench tasks across six repositories, the team found that once five tasks preceded the current one, 30 percent of tool calls repeated an earlier action. Claude Code loaded 23 tool definitions on every turn while 16 were never called, and three tools covered 98 percent of calls. Ten failed runs were 17 percent of tasks but 32 percent of total spend.
Timing adds pressure. OpenAI confirmed in its Help Center on 31 October 2026 that from December, Plus, Pro and Business plans share one token allowance across ChatGPT and Codex, with Instant chat exempt and no allowance sizes published yet. Chat and coding will draw from the same pool, so wasted agent tokens will cost more than they did when the two budgets were separate. A plugin that trims repeat spend is worth setting up before that change lands.
What you need
You need one of the supported agents, signed in any way it supports, and Python 3.10 or newer on your PATH. The plugin needs no API key of its own and never handles credentials, so any plan or login works. It needs no GPU. The repository is Apache 2.0 licensed and public at github.com/microsoft/TokenEconomizer, where it showed 7,473 stars when checked on 17 November 2026.
Check the version of your agent first. The README lists the versions its commands were tested on: 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. It also says newer versions have not been tested yet, so if your install is newer, the steps below should still work, but check the README for updates before you start.
Install TokenEconomizer on Claude Code
Run these commands in the folder where you want to keep the clone. Claude Code runs the plugin from the clone, so leave it in place.
git clone https://github.com/microsoft/TokenEconomizer.git
claude plugin marketplace add "$PWD/TokenEconomizer"
claude plugin install tokeneconomizer@tokeneconomizer
Start claude, trust the folder when asked, and run /tokeneconomizer:status, allowing its script if prompted. Once per machine, and again after Claude Code updates, run /tokeneconomizer:toolprune refresh-catalog. That command records every tool a session loads, so tool pruning can consider all of them.
Install TokenEconomizer on Codex
git clone https://github.com/microsoft/TokenEconomizer.git
codex plugin marketplace add "$PWD/TokenEconomizer"
codex plugin add tokeneconomizer@tokeneconomizer
Start codex, choose Trust and continue for the folder, then at the Hooks need review prompt choose Trust all and continue. The hooks take effect from your next Codex session, so quit with /exit, start codex again, and check with $tokeneconomizer:status. Note that Codex before version 0.141.0 does not run plugin hooks at all, so update Codex first if you are on an older build.
Install TokenEconomizer on the Copilot CLI
git clone https://github.com/microsoft/TokenEconomizer.git
copilot plugin marketplace add "$PWD/TokenEconomizer"
copilot plugin install tokeneconomizer@tokeneconomizer
Start copilot, choose Yes, and remember this folder for future sessions, and run /tokeneconomizer:status, choosing Yes to run its script. As with Claude Code, run /tokeneconomizer:toolprune refresh-catalog once per machine and again after Copilot updates. Keep the marketplace path absolute, as in the commands above. The Copilot CLI reads a relative path such as ./TokenEconomizer as the name of a GitHub repository, which fails.
Install TokenEconomizer on Pi
pi install git:github.com/microsoft/TokenEconomizer
Start pi and run /te status. Pi uses shorter command names: /te instead of /tokeneconomizer:. Opencode support is experimental, tested only on versions 1.19.5 and 2.2.0, so treat it as a trial rather than a settled setup.
How to check it is working
Run the status command for your agent. If the install worked, it prints a short status block showing what the plugin learned and did in this repository, and what your sessions cost. The commands are /tokeneconomizer:status on Claude Code and the Copilot CLI, $tokeneconomizer:status on Codex, and /te status on Pi. From a terminal inside the repository you can also run ~/.tokeneconomizer/bin/te status, which is free. A command typed inside an agent costs one model turn.
Give it a few tasks before you judge it. Savings build over time. In the paper, most repositories cost more at first, but all were cheaper by the sixth task. That pattern follows from how the plugin learns: it has nothing to reuse until it has seen a few sessions in the same repository.
What the three mechanisms do
Micro-skills remember how the repository works. Sessions keep rediscovering the same facts: a build step that must run first, the spelling of a command that works here, an environment variable a command needs, or where generated files live. The plugin learns such facts from failures that repeat across sessions and from a model that reviews recent sessions every three sessions and proposes facts. A fact enters the prompt at the start of each session once three sessions have confirmed it, and it is dropped when later sessions contradict it. Micro-skills is off by default, because its proposer adds model calls. Turn it on with config set microskills=on inside the agent, or add --global to switch it on for every repository.
Tool pruning stops loading tools that go unused. Every loaded tool definition is sent with every request. A tool that goes unused over ten 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. Shell, read, write and edit tools are always kept. One command brings a pruned tool back: toolprune restore. On Django with Claude Code, the first request on the second task fell from 43,351 to 16,295 prompt tokens once pruning applied.
The loop guard steps in when a turn is stuck. It learns a turn budget of 1.25 times the 90th percentile of successful run lengths. Cheap rule checks flag repeated failures or dense errors, and a judge model decides whether the agent is stuck at 0.7 confidence or higher. A stuck agent gets one redirect, a short note added to its context to try another approach. If the turn is still stuck after that, the plugin tells you how to stop it. It never stops a turn itself, so the call stays yours.
What the results actually show
The paper ran five agent and model combinations on the same 277 SWE-Bench tasks from six repositories, with each task as its own session and each repository's tasks in order, starting with nothing learned. Costs include every model call the plugin made. Mean cost fell in every one of the 30 repository and combination cells, by 5 to 40 percent within cells.
| Setup | Mean cost change | Pass@1, default | Pass@1, with plugin |
|---|---|---|---|
| Claude Code with Sonnet 5 | 23.6% lower | 74.7 | 76.0 |
| Claude Code with Opus 4.8 | 30.9% lower | 74.0 | 73.0 |
| Codex with GPT-5.6 Terra | 24.7% lower | 73.8 | 74.7 |
| Codex with GPT-5.6 Sol | 26.1% lower | 80.1 | 81.7 |
| Copilot CLI with Sonnet 5 | 18.4% lower | 75.0 | 77.6 |
Task success rose in four of the five settings and fell 1.0 point on Claude Code with Opus 4.8. On Claude Code alone, tool pruning saved 13.2 to 17.7 percent, micro-skills 11.8 to 14.3 percent, and the loop guard 5.4 to 7.1 percent. Results also held outside SWE-Bench: costs fell 16.0 to 21.2 percent on Web-Bench and 16.5 to 19.6 percent on CredData, while security-audit runs on ReposVul saw only 6.4 to 9.3 percent, because shorter runs leave less to remove.
Read those numbers as benchmark evidence, not a promise for your workflow. SWE-Bench tasks are GitHub issues run in order in the same repository, which is exactly the pattern the plugin exploits. Your savings depend on how often you return to the same repository, how many tools your agent loads, and how often your sessions loop. Run the status command after a week of real work and compare the reported cost with the week before. That comparison is the only number that matters for your setup.
What to do if it fails
If the plugin does not appear, check the version range first. The README says its commands were tested on 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, with newer versions untested. Update the agent or check the README for a newer supported range.
If the marketplace add step fails on the Copilot CLI, check the path. A relative path is read as a GitHub repository name, so use the absolute path form from the commands above, with "$PWD/TokenEconomizer" run from the folder that holds the clone.
If Codex shows nothing after install, remember the hooks start on the next session. Quit with /exit and start codex again, then check $tokeneconomizer:status. If the Hooks need review prompt never appeared, check that Codex is on 0.141.0 or newer, since older builds do not run plugin hooks.
If a tool you need disappears from the agent, the plugin pruned it after it went unused. Run toolprune restore to give it back. Restored tools are not removed again.
If the plugin itself errors, your session carries on as if it were not installed. The README says the plugin announces each action in one line and fails open, so a fault costs you the savings, not the session. To update, run git pull in the clone. Codex needs the codex plugin add line again after the pull, and Pi updates with pi update --extensions.
Frequently asked questions
Yes. The plugin needs no API key of its own and never handles credentials, so any plan or login works. Its own model calls run through your agent, on the same plan or login, and their cost is included in the cost figures it reports.
The paper reports 18.4 to 30.9 percent lower mean cost on SWE-Bench, with savings in all 30 repository and combination cells. Your result depends on how often you work in the same repository and how much repeat work your sessions do. Savings build over time, and the paper found all repositories cheaper by the sixth task. Check the status command after a week and compare with the week before.
No. What the plugin learns stays on your machine in `~/.tokeneconomizer`. Its model calls go through your own agent, not to a separate service. The plugin is Apache 2.0 licensed and its source is public, so you can read exactly what it stores.
Yes. The same clone serves Claude Code, Codex, the Copilot CLI and Pi, with install commands for each above. Each agent reads the same learned state for a repository, so facts learned in one agent carry over to the others. Experimental support also covers opencode, Cursor Agent, Grok Build, Hermes Agent, Antigravity CLI, and Factory Droid.
Micro-skills uses a model to propose facts every three sessions, which adds model calls of its own. Tool pruning and the loop guard are on by default because they save more than they cost from the start. Turn micro-skills on with `config set microskills=on` once you have run a few sessions in a repository and want the plugin to remember how that repository works.
Conclusion
To install TokenEconomizer is to give your coding agent a memory for the repository it works in. The install is a clone, a marketplace add and a plugin install, and the defaults already switch on tool pruning and the loop guard. The measured saving on SWE-Bench was 18.4 to 30.9 percent, with task success about the same, and the saving grows as the plugin sees more sessions in the same repository. With ChatGPT and Codex sharing one token allowance from December, that kind of repeat waste is the first thing to cut.
If you want to see what the saving is worth in money, run your session totals through the AI cost calculator on PromptStaging and compare a week with the plugin against a week without it. The general guide to cutting token usage covers the other levers, such as shorter prompts and smaller context, that stack with what the plugin does.
Sources and references
- TokenEconomizer GitHub repository (microsoft/TokenEconomizer), README, read 18 November 2026: https://github.com/microsoft/TokenEconomizer
- TokenEconomizer paper, arXiv 2610.22732, "TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents", published 15 October 2026
- MarkTechPost, "Meet TokenEconomizer: Microsoft's Plugin That Cuts Coding Agent Costs by Up to 30.9%", 30 October 2026: https://www.marktechpost.com/2026/10/30/microsoft-tokeneconomizer-coding-agent-cost-control/
- OpenAI Help Center, "Understanding ChatGPT and Codex usage limits", updated 31 October 2026, as reported 31 October 2026: https://automater.ai/news/chatgpt-codex-shared-token-allowance-december/
- Claude Code changelog v2.1.314 and v2.1.316 notes, via vibestacklab radar, read 31 October 2026 (version context only)