TokenEconomizer
Benchmarks measure coding agent cost per task, while token waste repeats across sessions in one codebase. TokenEconomizer, a plugin from Microsoft Research and UC Berkeley, leaves the agent unchanged and learns from each repository's history. It injects facts earlier sessions already found, removes tools earlier sessions never used, and nudges the agent once when it keeps repeating an error. On 277 SWE-Bench tasks the authors report 18.4 to 30.9 percent lower mean cost across five agent and model combinations. As of 1 December 2026 it has 8,284 stars, is MIT licensed, and the latest release is v0.1.0 from 26 October 2026. It works with Claude Code, Codex, Copilot CLI and Pi.
Repo: https://github.com/microsoft/TokenEconomizer
What you get
- Micro-skills: facts earlier sessions already found, stated at the start of each session once confirmed, and dropped when later sessions contradict them
- Tool pruning: tools that go unused are left out of later sessions through the agent's own settings, and one command brings them back
- Failure-loop intervention: one redirect when a turn keeps hitting the same failures, and it never stops a turn itself
- Works with Claude Code, Codex, Copilot CLI and Pi, with experimental support for opencode, Cursor Agent and others, and everything it learns stays on your machine
The saving is in the repeat work: the second session in a repo should not pay to rediscover what the first one already learned.
Quick poll
What would you use TokenEconomizer for first?
- Cutting my coding agent bill on a repo I use daily
- Trying the micro-skills on a repo with repeated setup steps
- Pruning unused tools from my agent sessions
- Reading the paper first
Vote in the comments.
If you found TokenEconomizer interesting, I write about tools like this every week in The AI-Native Engineering Leader, what actually works for engineering leaders building with AI agents, and what to skip.
Top comments (2)
The framing that "the second session shouldn't pay to rediscover what the first one learned" is the right way to think about it — the recurring cost in a repo is almost never the hard task, it's the setup/orientation tax paid on every cold start. Two questions from running something similar by hand: (1) how does it handle a micro-skill that was true last week but silently went stale after a refactor? We've been burned by cached "facts" that were confidently wrong, and the failure is worse than no fact at all because the agent trusts it. Sounds like the "dropped when later sessions contradict them" rule covers it, but contradiction detection is the hard part. (2) On tool pruning — does an un-pruned-but-newly-relevant tool ever get surfaced again proactively, or only when you run the restore command? A repo's tool needs drift over time, and I'd worry about pruning a tool right before the week you finally need it. Either way, learning that stays local is the right default.
the second session in a repo should not pay to rediscover what the first one already learned. eighteen to thirty percent cheaper is just the receipt for that.