Your Coding Agent Is Burning Tokens Relearning Your Repo. This Project Fixes That.
If you've been running a coding agent against the same repository for weeks, you've probably noticed it keeps figuring out the same things over and over—how to run the tests, which build step has to come first, which tools it never actually uses. You're paying for that rediscovery every single session. TokenEconomizer, a project from UC Berkeley and Microsoft Research, tackles that waste by having the agent learn from its own past sessions in a repo, without touching the agent itself.
What It Does
TokenEconomizer is a black-box cost-control layer for coding agents. It doesn't modify the agent—you point it at sessions an agent has already run in a repository, and it uses that accumulated experience to make future sessions cheaper. It works with Claude Code, Codex, GitHub Copilot CLI, and Pi, and it's written in Python (3.10+) under Apache 2.0.
The README lays out three mechanisms. Micro-skills capture how a repository actually works—facts like "run tests with python -m pytest"—so sessions stop rediscovering them. Tool pruning skips tools that never get used in a given repo (keeping Read and Edit, say, while leaving Notebook and Browser out). Failure-loop intervention watches for an agent stuck repeating the same error and steps in with a nudge to try another approach. Each of these learns from what happened before and applies the lesson to what comes next.
Why It's Cool
-
The numbers are the pitch. On SWE-Bench tasks, the project reports 18.4–30.9% lower mean cost across five agent–model combinations. It was cheaper in all 30 repository × combination cells, and Pass@1 went up in 4 of 5. That last part matters—you're not trading quality for savings.
-
It's genuinely black-box. You don't have to fork your agent, wrap its internals, or wait for the vendor to ship a feature. It learns from sessions that already happened, which means the integration surface is small and the agent stays whatever it was.
-
The waste it targets is real and boring. Re-learning a repo, carrying tools you never use, and spiraling on the same error are exactly the kinds of costs that don't show up as a bug but do show up on your bill. Naming them as three distinct mechanisms is a nice bit of design clarity.
-
It gets better with repetition. The premise is experience-driven: the more you work in a repository, the more there is to learn from. That's a sensible fit for the way people actually use coding agents—deep in a handful of repos, not shallow across hundreds.
One honest caveat from the README itself: results vary by combination. Claude Code with Opus 4.8 saw cost drop 30.9% but Pass@1 slipped by 1.0, while Copilot CLI with Sonnet 5 got a more modest 18.4% cost cut and a +2.6 Pass@1. Worth reading the per-combination breakdown before assuming your setup lands on the best end.
How to Try It
Start at the repository. The README notes Python 3.10+ as a requirement, and the project page and arXiv paper (2610.22732) are linked from the top if you want the methodology before you install anything.
- Check the repo's setup instructions for installation—the README is the source of truth here, and it's worth reading the full (untruncated) version for the exact commands.
- Point TokenEconomizer at a repository where you already run a coding agent regularly. The more session history there is, the more it has to learn from.
- Run your agent as usual and compare session costs against your baseline.
Since it's a black-box approach, you shouldn't need to change how your agent is invoked beyond whatever the project's own wiring requires. If you're evaluating it, the SWE-Bench results give you a reasonable expectation to test against: cheaper, and usually not worse on correctness.
Final Thoughts
TokenEconomizer is aimed at people who run coding agents in the same repos day after day and have watched the bills climb. If that's you, the combination of measurable cost reduction and a no-modification integration is worth a serious look. If you spin up agents on a new codebase every time, the experience-driven part has less to work with. Either way, the idea—treat an agent's session history as a resource to mine for savings—is a practical angle on cost control that more tooling should probably take.
Follow @githubprojects for more developer tools and open source projects.