AI coding agents start every session from scratch, so teams pay again and again for the same discovery, the same unused tools and the same failed approaches. TokenEconomizer, an open-source plugin from UC Berkeley and Microsoft, learns from past sessions in a repository and cut mean cost by 18.4–30.9% on benchmark coding tasks, without changing the agent or the model. The PM call: the cost of an AI feature is not only the model price but how often the AI repeats itself. Measure the cost of each successful task, not of each token, and design for the second session.
What happened
Researchers from UC Berkeley, Microsoft Research and Microsoft Security profiled Claude Code on SWE-Bench coding tasks and found three kinds of waste. The agent redid discovery it had already done: once a repository had at least five completed tasks, 30% of its tool calls repeated an action from an earlier task there. It was sent descriptions of tools on every turn that it never called. And failed tasks took a much larger share of spend than their number suggested. TokenEconomizer is an open-source plugin that reads past session logs and acts on them in three ways, without changing the agent or the model. It writes one-line, repository-specific notes (micro-skills), added only once several sessions confirm a pattern and retired if later sessions contradict them. It prunes tools that the repository's history says are unlikely to be used, always keeping the core run and edit tools and letting pruned ones be restored. And when a judge model decides the agent is stuck in a failure loop, it gives the agent a short note suggesting a different approach; in the open-source version, if the agent is still stuck after the note, it alerts the developer rather than stopping the work. Tested on SWE-Bench tasks across several repositories and agent-model combinations, starting with no history, it cut mean cost by 18.4–30.9% while success rates stayed broadly stable. The reported savings include the plugin's own model calls, it needs no API key of its own, and what it learns stays on the developer's machine.
A scenario you might face
Example: A platform PM is rolling out an AI coding assistant to 40 internal engineering teams, each working in the same repositories every day. Finance has flagged that agent spend is growing faster than usage, and the quick fix on the table is to lower the model's reasoning effort for everyone. The PM proposes a different test first: a four-week pilot of a learning plugin such as TokenEconomizer in five of the busiest repositories, measuring cost per merged change and task success against teams on default settings. She warns finance that the first few tasks in each repository may cost more while the plugin learns, so week one will look worse. She also leaves the one-off migration projects, where each task touches unfamiliar code and memory helps least, out of the savings forecast.
What changes in your practice
This week, take last month's spend on your AI coding agent or agent feature and divide it by successful tasks, not by tokens or sessions. Then read ten session logs from one repository or customer account and count how many tool calls repeat work done in an earlier session. If that share is high, memory is likely your cheapest saving; if it is low, look for the waste elsewhere before you touch the model.
Questions for your team
- 01What does one successful task cost us today, including retries and failed runs, and who owns that number?
- 02How much of our agent's work in a repository repeats what it already worked out in an earlier session?
- 03If we add memory, how many sessions does it take to pay back, and what share of our users return to the same codebase often enough to get there?
- 04When a learned note goes stale, how would we know, and how quickly would it be retired?