The bill that repeats itself
For example, a team runs a coding agent on its codebase every day. Each step, the agent sends the AI model its instructions, a description of every tool it could use and the whole conversation so far, and pays for all of it again, by the token (a small piece of a word). In tests on six large codebases the agent carried 23 tools, yet no codebase called more than 7, and failed tasks were 17% of the work but 32% of the spend.
Two couriers, one codebase, five days
- Backpack re-sent with every request
- Coins tokens you pay for
- Doors ways to run the tests
- Note a fact kept for next time
Default agent
0 coins
Your agent
0 coins
Real tasks from the paper: django-10554 on Claude Code with Sonnet 5; sympy-13615 and sphinx-11445 on Claude Code with Opus 4.8. Totals: Claude Code with Sonnet 5 over 277 tasks (tool trimming alone 13.2% cheaper; TokenEconomizer 23.6% cheaper). The couriers, doors, days and coins are drawn by us.
The surprise is the tool list: dropping 19 never-called tools cut a Django task's first request from 43,351 tokens to 16,295. Over 277 tasks TokenEconomizer cut cost 18–31% and passed more tasks in four of five setups; turning reasoning effort down saved 17–46% but lost up to 10 points.
Switch off unused tools by hand today. Then install the plugin on your busiest codebase, turn on its learned facts, and compare a week of bills.
Join free to read the rest
Join free to score your team, see what to check before you bet on it, get the first moves step by step, and learn how you'll know it's working.
Is it for you?
Which fix fits you?
The person who pays for the agent answers for the team
1Does it load tools or MCP servers it never uses?
Notebook or scheduling tools.
Trim them by hand today.
2Does it trip over the same setup fact each session?
Trying a test tool that is not installed.
Turn on learned facts.
3Do some runs drag on and still fail?
Editing one file again and again, never testing.
The loop guard steps in.
Each yes points to one fix below.
How much unused tool text do you send?
Anyone paying for a coding agent. The figures in the boxes are our example: type your own.
Before the caching discount; the paper gives no prices. 27,000 is the Django figure below.
Before you bet on it
Like the courier: the more it walks the same route, the more a remembered route saves.
277 benchmark bug fixes
Real developer sessions
The tested version, which could stop a run
The released plugin, which only tells you how
The plugin's pruning: 13–18%
Trimming by hand (we assume close)
Where does TokenEconomizer save the most tokens?
- 18–31% cheaper: bug fixes, task after task, in one large codebase.
- 16–21%: a web project built over 20 linked tasks.
- 16–20%: scanning many codebases for leaked keys, from trimming and the loop guard alone.
- Only 6–9%: short security scans, a new codebase each time.
Your first moves
Trim by hand
-
Switch off the tools and MCP servers your agent never calls; keep shell, read, write and edit.
You should see: A smaller first request, same tasks passing.
Install the plugin on your busiest codebase
The project's own commands for Claude Code; it needs Python 3.10 or newer and no key of its own.
-
Install it.
You should see: It appears in Claude Code's plugin list.
Show the command
git clone https://github.com/microsoft/TokenEconomizer.git claude plugin marketplace add "$PWD/TokenEconomizer" claude plugin install tokeneconomizer@tokeneconomizer
-
In your codebase, check it and turn on learned facts (off by default).
You should see: A status block; facts appear after a few sessions.
Show the command
/tokeneconomizer:status /tokeneconomizer:toolprune refresh-catalog /tokeneconomizer:config set microskills=on
How much does TokenEconomizer cost?
Free, MIT licence
On your agent's plan; included in the paper's savings
A little more while it learns
How you'll know
Compare the bills
Start some sessions as TE_DISABLE=1 claude and compare cost per finished task in the status report.
Under the hood
To see where those tokens go, follow one real bug. You type a request; Claude Code, an app on your computer, works on your files; the AI model decides each step and sees only what Claude Code sends.
Why do coding agents waste tokens on unused tools?
How one bug gets fixed, step by step
A real bug in SymPy, a free maths library, fixed with Claude Code.
You type: fix this bug
Claude Code is an app that works on your files.
Sources: [1]
Those 27,000 go out again every turn; prompt caching discounts repeated text but does not make it free. Tools from an MCP server (a program that adds tools) are listed the same way, used or not.
The fix and its methods
The fix: the same task, with TokenEconomizer
TokenEconomizer runs beside Claude Code, reads each finished session's log on your machine, and acts only through Claude Code's settings and the start of the prompt.
Request 1
Without23 tool descriptions
With TokenEconomizerUnused tools left out, plus a note: use SymPy's own test runner
Running the tests
WithoutThree tries
With TokenEconomizerStraight to the right runner
A run in circles
WithoutRuns on
With TokenEconomizerA judge model nudges it
Whole task
Without15 turns
With TokenEconomizer11 turns
Afterwards
WithoutLessons lost
With TokenEconomizerFacts confirmed; a wrong one dropped
Method 1: Tool pruning, stop paying for unused tools
A tool unused across enough sessions goes on Claude Code's disallowed list for that codebase; one command restores them all. Alone, this cut cost 13–18% on Claude Code.

Method 2: Micro-skills, remember what worked
A model proposes one-line facts from recent sessions. A fact is used once three sessions confirm it, and dropped when a later one contradicts it.

Method 3: Loop guard, step in when a run circles
When a run repeats an error or runs far past this codebase's usual length, a judge model checks it; if stuck, the agent is told what it keeps doing and asked to try another idea.

Sources
Check our working
- Li et al., TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents (arXiv 2610.22732)
- microsoft/TokenEconomizer: project README (GitHub)
- Model Context Protocol: Architecture overview (official documentation)
Found this useful? Send it to someone who should read it.