People who use AI to program intelligent agents probably have this experience: every time you open a new session, it has to touch your project again, and you are paying for this part of the token every time.

Microsoft Research and UC Berkeley have created a free plug-in, TokenEconomizer, to solve this problem. On the same 277 programming tasks, it reduced the cost of Claude Code, Codex and GitHub Copilot CLI by 18.4% to 30.9%, without changing a single line of the agent itself.

It learns three things from the sessions you've run in this repository:

One is to remember facts that the agent repeatedly rediscovers, such as which command is used to run the test for this project. The second is to stop tools that are never used - the description of each tool will be sent with each request, and the more you hang, the more expensive it will be. The third is to remind the agent to change paths when it is found that a certain round is stuck on the same error report.

The test covered 30 "warehouse + agent" combinations, all of which reduced costs; the number of solved problems increased for 4 of the 5 agent configurations.

Claude Code users have three commands to install: clone microsoft/TokenEconomizer on GitHub, use claude plugin marketplace add to add it to the local plugin market, and then plugin install to install it.

The second idea is that you can actually do it yourself without a plug-in: check how many MCP tools you have installed, and turn off the ones you don’t need first, and you will see changes in your bills immediately.