What it is

TokenEconomizer is a free open source plugin. It cuts the cost of coding agents. A coding agent is software that writes and edits code for you. It works with Claude Code, Codex, the GitHub Copilot CLI, and Pi. Microsoft Research and UC Berkeley built it.

The code is on GitHub under the Apache-2.0 license. The project has 6,205 stars.

The plugin does not change your agent. It does not change the model. It learns from sessions your agent already ran. A session is one run of the agent in one repository. A repository is a folder that holds one code project and its history. The plugin uses that experience to cut waste in later sessions.

The paper reports clear numbers. On 277 SWE-Bench tasks from six repositories, mean cost fell 18.4 to 30.9 percent. SWE-Bench is a test set of real software tasks. The test used five agent and model combinations. Cost fell in all 30 repository and combination cells. Pass@1 rose in four of five combinations.

Pass@1 is the share of tasks the agent solves on the first try.

On Web-Bench, cost fell 16 to 21 percent. On two security-auditing benchmarks, cost fell 6 to 20 percent. Every task there sat in a new repository. Costs in these numbers include the plugin's own model calls.

How it works

Three mechanisms do the work. The first is micro-skills. A micro-skill is a short fact the plugin learned about a repository. Sessions keep rediscovering the same facts.

A build step must run first. A command has a spelling that works here. An environment variable is needed.

The plugin learns these facts from failures that repeat across sessions. A model also reviews recent sessions every three sessions and proposes facts. A fact is stated at the start of each session once three sessions confirm it. Later sessions can contradict a fact. Then the plugin drops it.

The second mechanism is tool pruning. Every loaded tool adds cost to every request. A tool that goes unused over 10 prompts across at least two sessions is left out. The same rule applies over five sessions of any length.

The plugin leaves the tool out through the agent's own settings. One command brings the tool back. Restored tools are never removed again.

The third mechanism is the loop guard. A turn is the agent's work on one prompt. A turn can get stuck in a loop. It repeats the same failures. The loop guard first learns how long a turn in this repository usually runs.

Then a judge model checks a turn that shows signs of looping. The judge must be at least 0.7 sure that the turn is stuck. Then the agent gets one redirect. A redirect is a short note that tells it to try another approach.

If the turn is still stuck, the plugin tells you how to stop it. It never stops a turn itself.

The plugin needs no API key of its own. Its model calls run through your own agent. They run on the same plan or login. Their cost is included in its reports. What it learns stays on your machine, in ~/.tokeneconomizer.

By default, tool pruning and the loop guard are on. Micro-skills is off by default. Its proposer adds model calls. You can turn each mechanism on or off per repository.

How to set it up

You need Python 3.10 or newer. You need one of the supported agents, signed in any way it supports. For Claude Code, run three commands. Clone the repository. Add the marketplace. Install the plugin.

Then start Claude Code and run /tokeneconomizer:status. The status command shows what the plugin learned and what your sessions cost. Other agents use the same commands with their own form. Codex uses $tokeneconomizer:status. Pi uses /te status.

Supported versions 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. Pi 1.2.0 to 1.3.0. The README says newer versions have not been tested yet.

Honest limits

Savings need time. The plugin starts with nothing learned. It learns only from sessions in the same repository. A repository you open once will not show savings. The gains in the paper came from repeated work in the same six repositories.

Some agents have partial support. Opencode, Cursor Agent, Grok Build, Hermes Agent, the Antigravity CLI, and Factory Droid are experimental. On the Antigravity CLI, only micro-skills without model calls works. Tool pruning is not available there. On Cursor Agent, session cost is unavailable. Check the README for your agent before you install.

The plugin's own model calls cost money. The fact proposer and the judge both call a model. Those costs are counted in its reports. That is why micro-skills is off by default. Turn it on only when you work in one repository often.

If any part of the plugin fails, your session carries on as if it were not installed. That is a safe design. But it also means a silent failure looks like no savings. Run the status command to check that it is active.

One more limit: the plugin works through what the agent already reads. It does not teach the agent new tools. It cannot fix a weak model or a bad prompt. It cuts waste. It does not add skill.

Verdict

TokenEconomizer solves a real problem. Coding agents repeat the same waste in every session. This plugin learns from that waste and cuts it. The measured savings are real: 18.4 to 30.9 percent lower mean cost, with success rates mostly up, not down.

The catch is patience. You need repeated sessions in one repository before the savings show. A developer who works in the same code base every day will gain the most. A developer who jumps between new repositories each day will gain little.

Try it if you use Claude Code, Codex, the Copilot CLI, or Pi. Install it in your main repository. Turn micro-skills on. Check the status command after a week. Watch the cost line before you judge it.

Follow along

I test AI tools and build in public: