Agent·

TokenEconomizer — Experience-driven cost control — What does it mean?

The news. On November 16, 2026, Microsoft Research, UC Berkeley and Microsoft Security released TokenEconomizer, an open-source plugin that learns from an agent's past sessions in a repository. On 277 SWE-Bench tasks from six repositories, run with five agent–model combinations, it lowered mean cost per task by 18.4–30.9%, was cheaper than the default in all 30 repository–combination pairs, and Pass@1 rose in four of the five combinations. The reported savings include the controller's own model calls. Read the release →

Picture a technician who services the same office building every week. On the first visit they search for the water shutoff, carry every tool in the van up six floors, and try the same stuck valve three times before calling for help. A good technician keeps a logbook for that building, so the second visit is shorter than the first. The shutoff location becomes one line in the book. The pipe camera they never used stays in the van. And when they catch themselves on the third identical attempt, the supervisor's call ("try the bypass instead") comes early rather than after an hour.

A coding agent without that logbook pays the first-visit price every time. The authors profiled Claude Code on 60 SWE-Bench tasks, running each repository's tasks in order, and found three kinds of waste. Once a repository had five or more finished tasks behind it, 30% of tool calls repeated an action from an earlier task in that same repository, while only 7% matched another repository's history. The agent was sent 23 tool descriptions on every turn, and 16 were never called. And the 17% of tasks that failed took 32% of the spending. All three are costs of context as a scarce resource: tokens that sit in the input and are billed on each turn without moving the task forward.

TokenEconomizer is the logbook. After each session it reads the session's log and updates a per-repository state, then acts through three levers that the agent already exposes. Micro-skills are one-line notes added to the starting instructions, but only after several sessions confirm the pattern, and a note is retired when later evidence contradicts it. Tool pruning hides tools that recent tasks left unused or that are judged irrelevant, which is a learned version of the tool-loading strategy choice; shell, read and edit are always kept, and a removed tool can be restored. Failure-loop intervention learns the repository's turn budget, asks a judge model whether a repeated failure is a real loop, and if so injects one short redirect. In the paper's setup a run that still repeats after the redirect is stopped; the released plugin alerts the developer instead of stopping the work.

The important design choice is that the controller adapts per repository instead of applying one fixed strategy everywhere. The authors tested three popular plugins, each with one configuration for all repositories: RTK (compresses command output), Serena (adds code-navigation tools) and RepoMap (adds a repository map). All three cut cost on Django and raised it on SymPy; on scikit-learn only RTK helped, and on Sphinx only RepoMap did. The other common lever, lowering the model's reasoning effort, saves as much or more money but pays for it in solved tasks, as the table below shows for one agent–model combination.

Method (Claude Code, Sonnet 5)Cost vs defaultPass@1Source
Default—74.7%project page
Medium reasoning effort−26.6%70.0%project page
Low reasoning effort−45.5%65.1%project page
RTK (fixed: compress output)−1.1%73.1%project page
RepoMap (fixed: add repo map)−1.4%74.1%project page
TokenEconomizer−23.6%76.0%project page

A worked example shows why the failure loop is worth its own lever. Hold three numbers from the profiling run fixed: 17% of tasks fail, and those failed tasks take 32% of the spend, so successful tasks are the other 83% and take 68%. Per task, a failed task costs 32 ÷ 17 ≈ 1.88 units of the average, and a successful one costs 68 ÷ 83 ≈ 0.82 units. So a failed task costs about 2.3× as much as a successful one (1.88 ÷ 0.82). The source does not split that extra cost by cause, but it names an agent revisiting the same error as the waste this lever targets. The tool side composes the same way (illustrative): if each of the 16 never-called descriptions were 300 tokens, that is 4,800 input tokens re-sent on every turn, or 192,000 tokens across a 40-turn session, before the agent does any work. The cost profile of an agent is dominated by this kind of replayed input, which is also why prompt caching matters.

The logbook only pays off when the technician returns to the same building. Experience-driven control is a bet that tasks repeat in the same environment, and the results track how true that bet is. Early tasks in a repository can cost more than the default while the controller learns, but cumulative cost fell below the default in every repository by the sixth task. On Web-Bench, where one project is built task by task, costs fell 16.0–21.2%. On the security benchmarks every task is a new repository, so micro-skills are switched off, and savings were smaller: 6.4–19.6%. The release post reports that each lever saves on its own and all three together save the most; the paper is arXiv 2610.22732.

Goes deeper in: Agent Engineering → Cost & Latency Engineering → The Cost Profile of an Agent

Related explainers

Frequently Asked Questions

Check what you knowMap your AI & GPU knowledge across every track — free, role-based