Today's AI open source · 2026-11-26
microsoft/TokenEconomizer
TokenEconomizer is a plugin that reduces the running cost of coding agents based on experience from previous sessions.
| Repository | github.com/microsoft/TokenEconomizer ↗ |
|---|---|
| Main language | Python |
| License | MIT |
| GitHub stars · forks | ★ 8,113 · 575 forks (as of 2026-11-26) |
| Created · last update | 2026-10-13 · 2026-11-25 |
| GitHub topics | agentic-ai, agentic-coding, ai-coding, ai-coding-assistant, anthropic, artificial-intelligence, claude-code, codex |
Overview
TokenEconomizer is a cost-reduction plugin for coding agents released by Microsoft Research, UC Berkeley and others. It does not change the agent itself; instead, it learns from sessions already run in the same repository to reduce waste in the next session. It supports Claude Code, Codex, GitHub Copilot CLI and Pi, with experimental support for opencode, Cursor Agent and others.
It works in three ways. Micro-skills remembers repository facts that would otherwise be rediscovered every session, such as the command for running tests or required environment variables, and provides them at session start. Tool pruning removes tools that have gone unused for a long time from the next session's configuration. The loop guard (Failure-loop intervention) checks with a judge model whether the agent is stuck when the same failure repeats, then inserts a short note into the context telling it to try a different approach.
It suits developers and teams who frequently run coding agents in the same repository and find token costs a burden. Each method can be turned on or off separately, and thresholds can be adjusted in the settings.
Why it is worth a look
It is a black-box approach that reduces cost using only accumulated session experience, without changing the model or agent, so it can be attached as-is to agents already in use. Notably, it breaks down the specific points where agent costs leak — relearning repository knowledge, sending definitions of unused tools, and failure loops — and addresses each one. Because it is a research output released alongside a paper, the reasoning behind its design can be traced.
Key features
- Micro-skills finds repository facts from repeated failures and periodic session reviews, provides only facts confirmed across three sessions at session start, and discards them if they conflict with later sessions.
- Tool pruning removes tools that have gone unused for a set number of prompts or sessions from the next session through the agent's own configuration, and this can be reverted with a single command.
- The loop guard uses a judge model to check turns where the same failure repeats, and if confidence is above a threshold, it inserts a note to try a different approach, but it does not stop the turn directly.
- It reports each action in a single line, and if part of the plugin fails, the session continues as if it had not been installed.
- According to the README, on SWE-Bench tasks the average cost across five agent–model combinations dropped by 18.4–30.9%.
What it is used for
- Use it when you repeatedly run Claude Code or Codex in the same repository and want to reduce token costs.
- Use it when you want to cut the time an agent wastes rediscovering test commands or build steps every time.
- Use it when you want to quickly notice agent sessions that get stuck repeating the same error.
Getting started
- Prepare a Python 3.10 or later environment.
- Follow the installation instructions in the repository README to install the plugin for the agent you use (Claude Code, Codex, GitHub Copilot CLI, Pi, etc.).
- Check the Settings section of the README and decide which features to use — Micro-skills, tool pruning, loop guard — and their thresholds.
- Run sessions in the same repository as usual and check the actions the plugin reports.
What to weigh
- It is under the MIT license, so commercial use and modification are free.
- The project was created in October 2026, so its settings and behavior may change, and support for some agents such as opencode and Cursor Agent is still experimental.
- It uses separate model calls for fact suggestions and loop judgments, so you should check which model is used and how much it costs.
- The cost-reduction and Pass@1 figures were measured by the repository's authors on SWE-Bench tasks, so results may differ on real repositories.
Related terms and companies
Sources
Written with AI assistance from the repository README and GitHub data. Star counts and other numbers are GitHub values as of the date shown; features and licensing can change, so check the repository.