Source: Microsoft Research blog, TokenEconomizer: Learning from Experience to Make AI Coding Agents More Efficient (2026-11-16); paper arXiv 2610.22732; code microsoft/TokenEconomizer. UC Berkeley, Microsoft Research and Microsoft Security.
The problem, measured
Profiling a coding agent on 60 SWE-Bench tasks run in sequence per repository found three recurring kinds of waste:
Rediscovery. Once a repo had five completed tasks, 30% of tool calls repeated an action from an earlier task in the same repo (7% matched another repo's history).
Unused tools. 23 tool descriptions went out on every turn; 16 were never called.
Failure loops. The 17% of tasks that failed consumed 32% of spend.
Three popular fixed-strategy cost plugins each helped in some repos and hurt in others, which argues for per-repository adaptation.
Architecture
A black-box controller that runs beside an unchanged agent and model. After each session it reads the log, updates a per-repo model, and acts through three mechanisms using only interfaces the agent already exposes:
Micro-skills. One-line repo-specific notes proposed from recurring patterns, added to the starting context only after several sessions confirm them, and retired when later evidence contradicts them.
Tool pruning. Drops tools history says are unlikely to be used, always keeping shell and edit tools; pruned tools can be restored.
Failure-loop intervention. A judge model decides whether a repeating failure is genuinely stuck; if so the agent gets a short redirect note, and if still stuck the developer is alerted rather than the run being killed.
It needs no API key of its own, keeps what it learns on the developer's machine, and reported savings net out its own model calls.
Results
277 SWE-Bench tasks, six repositories, five agent/model combinations: mean cost per task down 18.4% to 30.9%, with savings in all 30 repository-combination pairs and pass@1 up in four of five combinations.
Early tasks can cost more while it learns; cumulative cost dropped below default in every repo by the sixth task.
Each mechanism saves on its own; all three combined save most.
Sequential web development (Web-Bench): 16.0% to 21.2% lower. Security auditing, where every task is a new repo: 6.4% to 19.6% lower.
Lowering reasoning effort saved similar or more but degraded task success substantially.
Tradeoffs and failure modes
Cold start. Value depends on repeated work in the same repo; one-off repos see the smallest gains.
Stale notes. A micro-skill that was true last month can mislead after a refactor; the retirement rule is the safeguard, so check how quickly it fires.
Over-pruning. A rarely needed tool removed at the wrong moment costs a turn to restore, or a failed task if the agent doesn't ask.
Judge error. A false "stuck" verdict interrupts productive exploration; a false "progressing" verdict lets a loop burn tokens.
Benchmark shape. SWE-Bench tasks are bounded bug fixes; long feature work may show different waste patterns.
Review checklist
Measure your own waste first: repeated tool calls per repo, never-called tools per turn, and the share of spend in failed tasks.
Gate any learned note on repeated confirmation, and give it a retirement path.
Keep a non-prunable core tool set.
Escalate stuck loops to a person instead of silently killing or continuing them.
Compare against simply lowering reasoning effort, and track task success, not just cost.
Related entries
Other entries on context economics and caching (index subtopic 1.5) and on agents learning from their own history (1.2).