TokenEconomizer Cuts Coding Agent Costs 18–31% by Learning From Past Sessions
The waste hiding in every session
Every agent session begins by sending instructions, tool descriptions, and conversation history to the model. That overhead is the price of admission, and it recurs whether or not the task is novel. Without any mechanism for learning, an agent may rediscover how to run a repository’s tests, load tools it will never call, or spend dozens of turns circling the same error.
The root cause is structural rather than a model failure in the usual sense. Each session starts cold, even when the developer and the repository are anything but. The paper’s premise is that this cold start is where a meaningful share of the bill lives, and that it can be addressed without touching the agent or the model underneath it.
What TokenEconomizer actually is
TokenEconomizer is a black-box plugin. It runs alongside an existing coding agent rather than replacing it, requires no API key of its own, and keeps everything it learns on the developer’s machine. That last detail matters for teams working on proprietary code: the learned profile of a repository does not leave the laptop.
The design is deliberately conservative. The controller does not rewrite the agent’s prompt wholesale or swap models. It observes sessions, accumulates evidence, and makes small, reversible adjustments. Crucially, it revises its own decisions as new evidence arrives, and the savings it reports already account for the model calls the plugin itself makes. The advertised figure is a net number, not a gross one.
How the researchers found the waste
The team began by profiling Claude Code on 60 SWE-Bench tasks, real bug fixes in open-source Python projects, running each repository’s tasks in sequence. That sequencing is the methodological heart of the work: it mirrors how engineers actually use these tools, returning to a familiar codebase rather than hopping between unrelated ones.
The profiling surfaced three recurring categories of waste, which the available material does not itemize. More telling was what happened next. The researchers tested three popular open-source plugins, each built around a fixed cost-saving strategy. Each lowered costs in some repositories but not others. A heuristic that helped in one codebase did nothing, or worse, in the next. The conclusion was direct: cost control has to adapt per repository. That finding shaped everything that followed.
Mechanism one: micro-skills
The first mechanism is a set of micro-skills: one-line notes capturing repository-specific knowledge. A note might record the command that actually runs the test suite, or a quirk in how dependencies are installed. These notes are not added to the starting context on first sight. They are promoted only after several sessions confirm the pattern, which keeps a single unusual session from polluting the profile. If later evidence contradicts a note, it is retired.
The result is a lightweight, self-correcting memory, and its modesty is part of the appeal. The engineering world has spent two years asking which model writes better code, a question that increasingly resembles asking which hammer is better at building a house. Work like Five Open-Source Skill Libraries That Turn Coding Agents Into Real Engineers makes the same point from a different direction: accumulated, reusable skill matters as much as raw model capability. TokenEconomizer applies that insight to cost rather than competence.
Mechanism two: tool pruning
The second mechanism removes tools that a repository’s history suggests are unlikely to be used. Tool descriptions consume context on every turn, so a long tail of unused capabilities is a recurring tax. The pruning is not absolute: core tools for running commands and editing files are always retained, and removed tools can be restored. The plugin is making a bet about the future based on the past, and it keeps a way to unwind that bet when the past turns out to be a poor guide.
Mechanism three: failure-loop intervention
The third mechanism targets the most frustrating failure mode: the agent that is not slow but stuck. A judge model distinguishes between the two. If the agent is genuinely stuck, it receives a short note suggesting a different approach. If it remains stuck after the nudge, the plugin alerts the developer rather than stopping the work itself.
That escalation choice is worth pausing on. A controller that halts an agent on its own judgment would be a liability in production. One that raises a hand and lets the human decide acts as a collaborator. The design reflects an understanding that the cost of a wrong intervention can exceed the tokens it saves.
The results
The evaluation covered 277 SWE-Bench tasks from six repositories across five coding agent and model combinations, with each repository starting from zero session history. Average cost fell by 18.4 – 30.9%, and TokenEconomizer saved the most in all 30 repository-combination pairs, with no performance loss. Each mechanism saves on its own; combining all three produces the largest reduction.
The comparison that matters most is against the obvious alternative. Lowering the model’s reasoning effort saved similar or larger amounts, but caused substantial performance degradation. Cheaper tokens that produce worse code are not cheaper in any sense an engineering team cares about. TokenEconomizer’s savings come from removing waste rather than from asking the model to think less. That distinction also explains why a per-repository, evidence-driven controller outperforms a fixed heuristic: any static rule about what to cut will be wrong somewhere.
Savings compound with experience
There is an honest caveat in the numbers. Early tasks can cost more while the plugin learns. But cumulative costs fell below the default by the sixth task in every repository tested. In other words, the payback period the paper reports is six tasks, after which the cost curve crosses over and stays there.
This is the correct shape for a system built on experience, and it reframes how such a tool should be judged. A single-task benchmark would show TokenEconomizer losing. A realistic workflow, in which a team returns to the same codebase for months, shows it winning and pulling further ahead with use. The plugin is an investment, and the paper quantifies when it pays off.
Beyond bug fixing
The generality of the approach shows up in two additional evaluations. On Web-Bench, which involves sequential web development tasks, costs came in 16.0 – 21.2% lower. On security auditing, where every task starts in a new repository, costs fell 6.4 – 19.6%.
That second result is the more surprising one. If the plugin’s premise is repository-specific memory, a benchmark with no shared repository should neutralize it. The savings persist, though smaller, which suggests that some of the waste is not repository-specific at all: tool pruning and failure-loop intervention apply regardless of codebase. The finding also fits a broader shift toward agents that rebuild and extend existing software, a trend visible in AI Agents Are Reverse-Engineering Photoshop and Office: Inside the New Wave of Software Clones, where long-running work on familiar codebases is the norm rather than the exception.
Reproducibility notes
The paper reports average cost reductions of 18.4 – 30.9% on SWE-Bench, 16.0 – 21.2% on Web-Bench, and 6.4 – 19.6% on security auditing, with per-pair wins in all 30 SWE-Bench combinations and no performance loss. It specifies the benchmark suites, repository counts, and the five agent-model combinations. Several implementation details are not spelled out: the three categories of waste found in initial profiling, the exact promotion threshold for micro-skills, and the judge model used for failure-loop detection. Savings are stated to be net of the plugin’s own model calls, but the accounting method is not described, so treat the reported percentages as the paper’s own net accounting rather than an independently audited figure.
Engineers wanting to evaluate the plugin in their own workflow should replicate the paper’s setup: run tasks in sequence within a single repository, start from zero history, and track cumulative cost against a default configuration rather than judging any single task. Expect early tasks to cost more. The crossover, not the first data point, is the number that matters.
We covered shepherd meta agent uses in more detail elsewhere.
We covered learning defer expert tired in more detail elsewhere.