In short.
TokenEconomizer is an Apache 2.0 plugin from UC Berkeley and Microsoft researchers. It aims to make AI coding agents (Claude Code, Codex, GitHub Copilot CLI, Pi, and experimentally six others) cheaper to run in repositories you use often. Its headline savings (18.4 to 30.9 percent lower mean cost on SWE-Bench tasks) are the authors' own measurements, and support is tested only on narrow agent version ranges. It leaves the agent, model and weights unchanged and learns across a repository's past sessions using three mechanisms, and which of them work depends on the host. Micro-skills states short facts about how the repository works at session start once three sessions confirm them. On Grok Build these facts arrive with the session's first tool call instead, and the Antigravity CLI supports only model-free facts. Tool pruning works only on Claude Code (single tools), Codex (capability packages) and the Copilot CLI (whole MCP servers). It leaves out tools that went unused during its observation window, by default 10 prompts spread across at least 2 sessions, or 5 sessions of any length. The loop guard sends at most one redirect per turn when a judge model is at least 0.7 confident that a turn keeps hitting the same failures. It never stops a still-stuck turn itself; it only tries to tell you how to stop it, and whether that notice reaches you depends on the host. The loop guard is off on the Antigravity CLI. On Factory Droid the fact proposer and the judge stay off until the droid_sidecall setting is turned on. By default tool pruning and the loop guard are on and micro-skills is off. You need Python 3.10 or newer and a signed-in supported agent, and the plugin makes its model calls through your own agent with no separate API key. Its session-cost reports include its own model calls, but on Cursor Agent session cost is reported as unavailable. Nothing was run for this report; everything below comes from the repository's README and licence text.
Researched and written by an AI model and checked by a second AI model. How it works
The selected scope is one file: README.md in the microsoft/TokenEconomizer repository at commit 7042ea89dd5e5ecbc67ad865ad6e256e61be8bf0, plus the repository's LICENSE (Apache 2.0), captured beside it for rights. Not reviewed: the plugin and package source code, plugin/README.md, docs/PLUGIN.md, docs/ARCHITECTURE.md, docs/DROID.md, the experiments directory, the arXiv paper, the project page, the images and the tests. No installation, run or benchmark was performed, so claims about behaviour, savings, per-host feature support and compatibility are the authors' statements, not observed results. A NOTICE file, release tags and commit dates were not part of the captured evidence, so whether a NOTICE file exists is unknown.
The overview
What this resource is
TokenEconomizer is a plugin published in the GitHub repository microsoft/TokenEconomizer [https://github.com/microsoft/TokenEconomizer]. Its README is titled 'TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents'. The listed authors are researchers at UC Berkeley, Microsoft Research and Microsoft Security. The README links an arXiv paper [https://arxiv.org/abs/2610.22732] and a project page [https://tokeneconomizer.github.io]; neither was read for this report.
It targets coding agents that you run in a terminal or editor. The non-experimental hosts are Claude Code, Codex, the GitHub Copilot CLI and Pi. The experimental hosts are opencode, Cursor Agent, Grok Build, Hermes Agent, the Antigravity CLI and Factory Droid. The package is described as using only the Python standard library. The README does not give a release version number or a release date for the plugin itself.
Overall assessment
On the README alone, this is a specific, carefully documented tool built on a clear idea. Coding agents repeat the same costs in the same repository: they rediscover facts, send definitions of unused tools and loop on the same failures. The plugin learns from earlier sessions to trim that waste. The README gives a default for every threshold, says which agents each mechanism works on, lists tested version ranges, explains how to undo every action and describes its benchmark method. That level of detail helps a reader decide whether to try it.
There are three main reasons for caution. The savings figures are the authors' own and cannot be confirmed from the README alone. Tested support covers narrow, specific agent versions, and newer versions are explicitly untested. And the plugin runs hooks and scripts inside your agent sessions and edits project settings files. The plugin code itself was not reviewed, so its behaviour beyond what the README says is unknown. It looks most worthwhile for people who use Claude Code, Codex or the Copilot CLI repeatedly in the same few repositories and either pay per token or run into plan limits.
Who it is for
The README is aimed at developers who use one of the supported coding agents on the same repositories again and again. Its stated premise is that 'developers use the same agent on the same repository again and again, so much of that cost repeats'. People who want to lower spend on a pay-per-token API plan, or make a subscription plan go further, are the natural audience; the README says the plugin works with any plan or login the agent supports.
It fits less well if you mostly work in a new repository each time, because the mechanisms need several sessions of evidence before they act. The README does report smaller savings (6 to 20 percent lower) on two security-auditing benchmarks where every task is in a new repository, so it claims some benefit there, but those results were not examined here. It is also not suited to people who cannot install plugins or run local scripts in their agent. Windows users are limited on the experimental hosts: Cursor Agent and the Antigravity CLI are stated as macOS and Linux only, and Factory Droid was tested only on macOS. The README does not say whether the Claude Code, Codex or Copilot CLI installs were tested on Windows.
What it can do
Micro-skills learns short facts about how a repository works, in any programming language. Examples include a build step that must run first, a command spelling that works here (the README gives 'python -m pytest' where 'pytest' is missing, and 'npx tsc' where 'tsc' is), an environment variable a command needs, or where generated files live. A fact is stated at the start of each session once three sessions have confirmed it, and dropped when later sessions contradict it. Some hosts differ. On Grok Build, learned facts arrive with the session's first tool call, not at session start. On the Antigravity CLI, only the model-free facts are supported. On Factory Droid, the paid fact proposer stays off until droid_sidecall is turned on.
Tool pruning stops sending definitions of tools that went unused during its observation window, since every loaded tool's definition is sent with every request. By default the window is 10 prompts across at least 2 sessions, or 5 sessions of any length. It works only on Claude Code, where it leaves out single tools; Codex, where it leaves out capability packages; and the Copilot CLI, where it leaves out whole MCP servers. It leaves nothing out on Pi or on any of the experimental hosts.
The loop guard watches for a turn that keeps hitting the same failures. If a judge model is confident enough that the turn is stuck, the guard adds a short note to the agent's context suggesting another approach. It never stops a turn itself. If the turn is still stuck after its redirects, the plugin tries to show a one-line notice saying how to stop it, but whether and where you see it depends on the host. On Claude Code and Hermes Agent the plugin asks the model to repeat the line, so it may be reworded or left out. 'codex exec' prints no hook messages, so a headless Codex run does not show it. On opencode 2.x it goes to the opencode server's error output, not the terminal UI. On Hermes Agent, the notice reaching a person has not been verified. The loop guard is off on the Antigravity CLI. On Factory Droid the judge stays off until droid_sidecall is on, and until then only a rule-based backstop applies.
The README also names these features. A session-cost report includes the plugin's own model calls, except on Cursor Agent, where session cost is reported as unavailable. The 'status' command shows what was learned and done. The 'config' command shows and changes settings for one repository or globally. 'toolprune restore' gives removed tools back, and they are not removed again. An optional background import reads earlier Claude Code sessions (off by default). Environment variables such as TE_DISABLE=1 turn the whole plugin off for one session. What the plugin learns is stored on your machine in ~/.tokeneconomizer.
Using it
What you need
You need one supported agent, signed in by any method it supports, and Python 3.10 or newer on PATH. The README says the plugin needs no API key of its own and never handles credentials. For most hosts you also need git to clone the repository. Pi installs directly from the GitHub address with 'pi install git:github.com/microsoft/TokenEconomizer'.
The README lists these tested agent versions: 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; Pi 1.2.0 to 1.3.0 (Pi 0.99.x can load the extension by path); Cursor Agent 3.24.9 with cursor-agent 2026.11.05; Grok Build 1.0.70; opencode 1.19.5 and 2.2.0; Hermes Agent 0.22.5; Antigravity CLI agy 1.5.1; and Factory Droid 0.233.0. Older versions are marked not supported for Claude Code, Codex and the Copilot CLI, and the README says Codex before 0.141.0 does not run plugin hooks at all. It states that the commands were tested on the oldest and newest version in each range, and that newer versions have not been tested yet.
Cursor Agent and the Antigravity CLI use a POSIX shell launcher, so they are macOS and Linux only. Disk, memory and processor requirements are not stated. You must also accept each agent's trust prompts; for Codex this includes trusting the plugin's hooks.
How it works
The plugin hooks into each agent's own extension points and reads each finished session's log. Learned facts enter the agent's context at session start; on Grok Build they arrive with the session's first tool call instead. On Claude Code, Codex and the Copilot CLI, tools are removed through the agent's own settings, so the agent never has to learn a new tool. The README says the plugin leaves the agent's model, weights and code alone. It names four principles: work through what the agent already reads; count cost as it is billed, including cache pricing and the plugin's own model calls; protect task success by acting only on repeated evidence; and keep every action reversible.
Micro-skills draws facts from two sources. One is failures that repeat across sessions. The other is a model that reviews the recent sessions every k sessions (k = 3 by default) and proposes facts. The Antigravity CLI supports only the model-free facts. Tool pruning runs only on Claude Code (single tools), Codex (capability packages) and the Copilot CLI (whole MCP servers). It removes a tool that went unused over p = 10 prompts spread across at least m = 2 sessions, or over s = 5 sessions of any length. It writes the deny list only once your sessions in the repository have been idle for q = 60 minutes, or at the latest a day after the list formed. The reason is that changing the tools in a resumed conversation forces its whole history to be written to the prompt cache again.
The loop guard first waits until e = 5 turns in the repository have ended well, so it can learn how long a turn usually runs. After that, a turn showing signs of looping goes to a judge model. If the judge is at least c = 0.7 sure the turn is stuck, the agent gets a redirect, at most r = 1 time per turn. One case skips the judge: a turn that runs past b = 2.5 times its usual length while churning the same edits through the same failures. On most hosts the judge and the fact proposer run through your own agent, on the same plan or login. On Factory Droid they run through 'droid exec' and stay off until droid_sidecall is on; when on, they may use only Droid's read-only Read tool. On the Antigravity CLI the plugin makes no model call at all, so the proposer and the loop guard are off.
Setup
For Claude Code, the README gives three commands to run in the folder where you want to keep the clone: 'git clone https://github.com/microsoft/TokenEconomizer.git', then 'claude plugin marketplace add "$PWD/TokenEconomizer"', then 'claude plugin install tokeneconomizer@tokeneconomizer'. Then start claude, trust the folder and run '/tokeneconomizer:status', allowing its script if asked. Once per machine, and again after each Claude Code update, run '/tokeneconomizer:toolprune refresh-catalog'. Codex and the Copilot CLI follow the same clone-then-marketplace pattern with their own commands. Codex also requires you to approve its hooks and restart before they take effect. Keep the marketplace path absolute, because the Copilot CLI reads a relative path as the name of a GitHub repository.
Claude Code, Codex, the Copilot CLI and opencode run the plugin from the clone, so it must stay in place. For several hosts, updating means running 'git pull' in the clone. Pi uses 'pi update --extensions', Codex also needs its add line run again after the pull, and the Antigravity CLI needs its bundle rebuilt. Experimental hosts need extra steps, such as 'python scripts/build_plugin.py --droid' for Factory Droid or a symlink for opencode and Hermes Agent. For Hermes Agent, the README says to use the symlink instead of 'hermes plugins install'. Its reason is that this installer leaves the launchers behind when given the plugin directory, and refuses the whole repository at its security scan. The README does not say what the scan objects to, so the reason for the refusal is unknown, and the symlink route does not show that the scan's concern has been resolved.
How you type commands depends on the agent: '/tokeneconomizer:<command>' on Claude Code and the Copilot CLI, '$tokeneconomizer:<command>' on Codex and '/te <command>' on Pi. On several experimental hosts they run from a terminal through ~/.tokeneconomizer/bin/te. If the install worked, 'status' prints a short status block. The longer per-agent walkthrough, uninstall steps and troubleshooting are in plugin/README.md, which was not part of this review.
A worked example from the README
Here is a concrete case the README describes. In a repository where the 'pytest' command is missing, agent sessions keep failing and then discovering that 'python -m pytest' works. Once three sessions confirm that fact, micro-skills states it at the start of every later session, so the agent does not pay again to rediscover it. If a later session contradicts it, the fact is dropped. Micro-skills is off by default, so this needs 'config set microskills=on'. Alternatively, 'microskills=envfacts' learns only from repeated failures and makes no model calls.
For tool pruning, the README's animation shows Notebook and Browser tools being left out of a repository's later sessions. On Claude Code, a tool that goes unused over the observation window (by default 10 prompts across at least 2 sessions, or 5 sessions of any length) is left out, and its definition stops being sent with each request. You can check what was left out with '/tokeneconomizer:toolprune' and undo it with '/tokeneconomizer:toolprune restore'. For the loop guard, the README shows the notice format for a stuck turn: 'TokenEconomizer: this turn still looks stuck after a redirect (judge-stuck@0.82, 46 tool calls). Press Esc to interrupt it.' None of these behaviours were run for this report.
Assessment & evidence
Limits and risks
Evidence quality: the headline results come from the authors' own experiments, and the README reports them without confidence intervals or variance. Pass@1 changes are small and mixed. They are up in 4 of 5 combinations, by 0.9 to 2.6 points, and down 1.0 for Claude Code with Opus 4.8. The reviewed text does not say which mechanism settings were used for the benchmark runs. The benchmark harness covers only Claude Code, Codex and the Copilot CLI, so no measured savings are reported for Pi or the experimental hosts. Tasks ran in order within each repository, starting with nothing learned, so the results reflect repeated use of one repository.
Support limits: only specific agent version ranges were tested, newer versions are untested, and several hosts are experimental. Tool pruning is not available on Pi, opencode, Hermes Agent, the Antigravity CLI, Grok Build, Cursor Agent or Factory Droid. On Cursor Agent, session cost is reported as unavailable. On the Antigravity CLI only micro-skills' model-free facts work. On Grok Build, learned facts arrive with the first tool call, not at session start. Hermes Agent support is limited to the classic CLI and one-shot runs.
Behaviour caveats stated in the README: Claude Code shows the plugin's own lines only in its detailed transcript, so the plugin asks Claude to repeat the stuck-turn notice, and the model may word it differently or leave it out. 'codex exec' prints no hook messages. In headless runs, a flagged turn runs until it ends or reaches the agent's own limits. Changing tools in a resumed conversation forces the prompt cache to be rewritten, which is why pruning waits for idle time.
Safety and privacy: the plugin installs hooks, asks you to trust its scripts, writes project settings files (.claude/settings.local.json, .codex/config.toml, .github/copilot/settings.local.json) and stores learned data under ~/.tokeneconomizer. Its model calls run through your agent, so session content reaches whichever model provider your agent uses. Exactly what each call reads is documented in plugin/README.md, which was not reviewed. For Hermes Agent, the README says the normal 'hermes plugins install' command refuses the whole repository at its security scan, and recommends a symlink instead. The reason for the refusal is unknown from the captured evidence, and using the symlink does not show that the scan's concern has been resolved. The plugin's source code was not read or run, so claims such as 'if any part of it fails, your session carries on' are the authors' statements, not verified behaviour.
Reasoning behind this assessment
The assessment rests on three things the README sets out directly: the design (what each mechanism does and when it triggers), the operating limits (supported versions, defaults and per-agent differences) and the measured claims with their method. The design is concrete and checkable. Every threshold has a name and a default, and each mechanism can be turned off on its own or with an environment variable. The cautious choices are consistent with the stated goal of not hurting task success: a fact needs three confirming sessions, tools are removed only after a sustained period without use, there is one redirect per turn, turns are never stopped automatically, and tool removal can be undone.
Against that, the key claim of lower cost with comparable success is self-reported and was not independently reproduced. The README points to an experiments directory that reruns the SWE-Bench and Web-Bench experiments, which would let a reader check the claims, but it was not examined here. So this report treats the savings as the authors' reported results rather than established facts, and treats the plugin as worth a controlled trial rather than a confirmed saving.
Alternatives and manual equivalents
The README does not compare TokenEconomizer with other tools, so no competing product is assessed here. In principle, each mechanism has a manual counterpart that needs no plugin. You can write lasting repository facts, such as the right test command, into your agent's own project instruction file. You can turn off unused tool servers or tools in the agent's settings by hand. And you can interrupt a looping turn yourself. These are general observations, not claims from the README. The trade-off is that the manual route takes your time and judgement, while the plugin automates it from session history at the price of installing hooks and a model-based judge.
The plugin also offers lighter modes. 'toolprune=propose' only proposes a deny list, and nothing changes until you run 'toolprune apply'. 'microskills=envfacts' learns facts from repeated failures with no model calls.
Evidence reviewed
Two files were read in full: README.md at commit 7042ea89dd5e5ecbc67ad865ad6e256e61be8bf0 (about 32 KB) and the LICENSE file at the same commit (about 11 KB, standard Apache 2.0 text). The README supplied the description, setup commands, version table, settings table, per-agent behaviour, results and citation. The result figures, including the per-combination numbers, appear in the README text and in the alt text of its animated teaser image. The image itself, the paper, the project page and the plugin and experiment code were not reviewed.
Nothing was executed. No installation, run, benchmark or test was performed for this report, so every statement about behaviour is what the README says, not something observed.
Access & freshness
Costs
The README states no price for the plugin. It is distributed under Apache 2.0, and no licence fee is indicated. It uses no API key of its own: its model calls run through your own agent on the same plan or login, so they are billed or counted against the plan you already use. Python and a supported agent are prerequisites, and any cost of the agent is separate and not covered here.
With the defaults (tool pruning and the loop guard on, micro-skills off), the README says the plugin calls a model only when a turn shows signs of looping: a judge model checks whether the turn is stuck and, if it finds it stuck, writes a redirect. The README does not say how many separate model calls this involves. Turning micro-skills on adds the fact proposer's model calls, which run every k sessions (k = 3 by default). The README does not give the size of these calls in tokens or money; it points to the 'Model calls' section of plugin/README.md, which was not captured, so their absolute cost is unknown. Inside an agent, a plugin command such as 'status' costs one model turn; from a terminal it is free. The plugin's own model calls are included in its cost reports, except on Cursor Agent, which reports session cost as unavailable. They are also included in the paper's results.
All reported savings are the authors' own. On 277 SWE-Bench tasks from six repositories, mean cost was 18.4 to 30.9 percent lower across five agent and model combinations. Every one of the 30 repository and combination cells was cheaper, with cost down 5 to 40 percent within each cell. By combination, cost was lower by 23.6 percent for Claude Code with Sonnet 5, 30.9 percent for Claude Code with Opus 4.8, 24.7 percent for Codex with GPT-5.6 Terra, 26.1 percent for Codex with GPT-5.6 Sol and 18.4 percent for the Copilot CLI with Sonnet 5. Reported savings were 16 to 21 percent on Web-Bench and 6 to 20 percent on the two security-auditing benchmarks. Your own savings are unknown until you measure them in your repositories.
Licence and rights
The repository's LICENSE file is the standard Apache License, Version 2.0 text, and the README's licence section and badge also say Apache 2.0. Under that licence you may use, copy, modify, sublicense and distribute the work, including commercially. The conditions are: give recipients a copy of the licence, mark files you changed, and keep the copyright, patent, trademark and attribution notices in any source you redistribute. If the work includes a NOTICE text file, any derivative works you distribute must also include a readable copy of the attribution notices it contains, apart from any that do not relate to the derivative work. The licence includes a patent grant that ends for you if you sue claiming the work infringes a patent. The software is provided 'AS IS', without warranty. The licence grants no right to use the licensor's trade names, trademarks, service marks or product names, except as needed for reasonable and customary use in describing where the work came from and in reproducing the content of the NOTICE file.
In the captured LICENSE file, the appendix placeholder 'Copyright [yyyy] [name of copyright owner]' is left as in the template, so that file does not name a copyright holder. No NOTICE file was captured, so whether the repository contains one, and therefore whether the NOTICE condition applies, is unknown. Only the README was reviewed. Its images, badges and logos and the paper it links are separate items, and the README does not say whether they carry the same licence. The evidence also does not cover whether the third-party agents and models the plugin works with allow this kind of integration under their own terms.
Freshness
The reviewed copy was captured on 2026-11-13 from commit 7042ea89dd5e5ecbc67ad865ad6e256e61be8bf0. The README contains dated details: it records a Factory Droid check on 2026-11-05 and cites cursor-agent 2026.11.05. It lists tested versions up to Claude Code 2.1.310, Codex 0.164.0 and Copilot CLI 1.0.102. The commit date, release tags and any changelog are not in the evidence, so how actively the project is maintained is not established here.
The README says the commands were tested on the oldest and newest version in each listed range and that newer versions have not been tested yet. Check compatibility with the agent version you run rather than assuming it. The version ranges and benchmark figures in the README describe this commit only.
What to do next
Before installing, check that your agent version is within the tested range for your host and that Python 3.10 or newer is on PATH. Read plugin/README.md, especially the 'Model calls and API keys' section, to see exactly what the plugin's model calls read and how often they run. Then decide whether that is acceptable for your code and your model provider.
For a cautious trial, install it in one repository you use often and keep the defaults (tool pruning and the loop guard on, micro-skills off). Consider 'toolprune=propose' so that nothing changes until you run 'toolprune apply'. Use 'status' and 'toolprune' to see what it did, and 'toolprune restore' or TE_DISABLE=1 to back out. Turn on 'microskills=envfacts' for fact learning without model calls, or 'microskills=on' if you accept the extra proposer calls. On Claude Code, turn on 'history_import' right after installing if you want earlier sessions read. Compare your own session costs and task outcomes over several sessions before relying on the reported savings. To check the authors' figures, start with the experiments directory in the repository.
