TokenEconomizer
A plugin for Claude Code, Codex, GitHub Copilot CLI and Pi that learns from finished sessions to lower coding-agent cost per repository.
At a Glance
About TokenEconomizer
TokenEconomizer is an open-source plugin from Microsoft that reduces the cost of running coding agents on a repository. It works with Claude Code, Codex, the GitHub Copilot CLI and Pi, reads each finished session, and changes what later sessions in that repository are given. The accompanying paper reports lower mean cost on SWE-Bench runs across five agent–model combinations.
What It Is
TokenEconomizer is a black-box cost-control layer for coding agents. It leaves the agent's model, weights and code unchanged and treats a repository's stream of sessions as the unit to optimize. Learned data stays on the user's machine under ~/.tokeneconomizer. By default it makes no model calls of its own and needs no API key.
How the three mechanisms work
- Micro-skills: environment facts that sessions keep rediscovering by failing (for example, that
python -m pytestworks wherepytestis missing) are learned from recurring evidence and stated at the start of the next session. - Tool pruning: tools that stay loaded but go unused across consecutive sessions (five by default) are left out of later sessions through the agent's own settings. A single command restores them, and a propose mode lets users approve each deny list.
- Failure-loop intervention: a turn that repeats the same failing edit-and-test cycle gets one redirect. If it is still stuck, the plugin tells the user how to stop it and never stops a turn itself.
Each mechanism can be switched off or tuned separately, and optional paid helpers (an LLM fact proposer and a loop-guard judge) are off unless enabled.
Setup path
Installation requires one of the supported agents and Python 3.10 or newer. Claude Code, Codex and the Copilot CLI install from a cloned marketplace directory, while Pi installs directly from the git repository. Commands such as status, microskills, toolprune and config are available inside each agent or from a terminal through the te launcher.
Reported results
The README says that in the paper's SWE-Bench runs across 277 tasks from six repositories, mean cost was 18.4–30.9% lower across five agent–model combinations, and Pass@1 rose in four of five. The repository includes an experiments harness for rerunning the SWE-Bench and Web-Bench evaluations.
Community Discussions
Be the first to start a conversation about TokenEconomizer
Share your experience with TokenEconomizer, ask questions, or help others learn from your insights.
Pricing
Open Source
Apache 2.0-licensed plugin for Claude Code, Codex, GitHub Copilot CLI and Pi; no API key of its own needed.
- Micro-skills learned from recurring session evidence
- Tool pruning of unused tools
- Failure-loop intervention
- Learned data stays on your machine under ~/.tokeneconomizer
- No model calls of its own by default
Capabilities
Key Features
- Micro-skills learned from recurring session evidence
- Tool pruning of unused tools via the agent's own settings
- Failure-loop intervention with a single redirect
- Restore command to give back pruned tools
- Per-mechanism on/off and tuning settings
- Local storage of learned data under ~/.tokeneconomizer
- Cache-aware cost status reporting
- Experiments harness for SWE-Bench and Web-Bench
