← all repositories
microsoft/TokenEconomizer

Your coding agent keeps forgetting the repo. This plugin remembers for it.

TokenEconomizer learns from past sessions in a repo to cut the repeated waste — rediscovered facts, unused tools, failure loops — without touching the agent itself.

TokenEconomizer
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

TokenEconomizer is a plugin for Claude Code, Codex, GitHub Copilot CLI and Pi (opencode experimental) that cuts the cost of coding agents in repositories you work in repeatedly. It watches sessions the agent has already run, learns from them, and applies three fixes to future sessions: micro-skills (remembered repo facts like “run tests with python -m pytest”), tool pruning (stop sending tool definitions that never get used), and a loop guard that redirects a turn stuck repeating the same failure. The agent’s model, weights and code stay untouched.

The interesting bit

The whole thing works through what the agent already reads — facts are injected at session start, tools are removed via the agent’s own settings — so nothing depends on teaching the agent a new tool. And it counts cost the way you’re billed, including cached re-reads and the plugin’s own model calls, which run through your existing agent login. Everything it learns stays local in ~/.tokeneconomizer, and every action is reversible: contradicted facts get dropped, pruned tools come back with one command, and the loop guard never kills a turn — it just nudges and tells you.

Key highlights

  • 18.4–30.9% lower mean cost across five agent–model combinations on 277 SWE-Bench tasks; cheaper in all 30 repository × combination cells, with Pass@1 up in 4 of 5.
  • Savings held on Web-Bench (16–21%) and two security-auditing benchmarks with fresh repos per task (6–20%).
  • Each mechanism is independently toggleable, with tunable thresholds (fact confirmation count, pruning windows, judge confidence).
  • Fail-safe by design: if any part of the plugin fails, the session continues as if it weren’t installed.
  • Apache 2.0, Python 3.10+, from UC Berkeley and Microsoft Research, with a paper and interactive project page.

Caveats

  • Version support is narrow and explicit — e.g. Claude Code 2.1.300–2.1.310, Codex 0.153.1–0.164.0 — and older versions are simply not supported.
  • opencode support is experimental, tested on only two versions and not in the 2.x terminal UI.
  • The payoff depends on repeated sessions in the same repository; the paper’s own setup starts each repo’s tasks from nothing learned, so early sessions pay full price.

Verdict

If you run the same agent in the same repos day after day and watch the token bill, this is worth a look — the numbers are unusually thorough and the design is refreshingly conservative. If your work is one-off tasks in ever-changing repos, the micro-skills machinery has much less to chew on, though the loop guard still earns its keep.

Frequently asked

What is microsoft/TokenEconomizer?
TokenEconomizer learns from past sessions in a repo to cut the repeated waste — rediscovered facts, unused tools, failure loops — without touching the agent itself.
Is TokenEconomizer open source?
Yes — microsoft/TokenEconomizer is open source, released under the Apache-2.0 license.
What language is TokenEconomizer written in?
microsoft/TokenEconomizer is primarily written in Python.
How popular is TokenEconomizer?
microsoft/TokenEconomizer has 2.1k stars on GitHub.
Where can I find TokenEconomizer?
microsoft/TokenEconomizer is on GitHub at https://github.com/microsoft/TokenEconomizer.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.