ResearchExplainer

TokenEconomizer: how Microsoft Research cuts coding-agent token costs

TokenEconomizer learns from earlier sessions in a repository to add one-line facts, drop unused tools and redirect stuck runs. The paper reports 18.4 to 30.9 per cent lower SWE-Bench cost with similar pass rates; the shipped plugin uses different defaults.

TokenEconomizer is a cost controller for AI coding agents that learns from the agent’s own history in a repository. After each session it reads the log, then changes three things for the next one: it adds short, verified facts about the repository to the prompt, removes tool descriptions the agent never uses, and steps in when a run keeps hitting the same failure. It does not modify the agent, its code or the model. Microsoft Research published a blog post about it on 16 November 2026; the paper and the open-source plugin appeared in October.

The headline result is that, on 277 SWE-Bench bug-fixing tasks, TokenEconomizer lowered mean cost per task by 18.4 to 30.9 per cent across five combinations of agent and model, including the cost of its own model calls, while task success stayed close to the unmodified agent’s. The comparison that matters is with the cheapest alternative most teams already have, turning down reasoning effort. In the same experiments that saved similar or larger amounts but cut the pass rate by 1.8 to 10.3 percentage points.

For anyone paying for Claude Code, Codex or GitHub Copilot CLI by the token, the paper is also a careful account of where coding-agent money goes. This explainer covers that diagnosis, each of the three mechanisms and its settings, the benchmarks and their conditions, the trade-offs the authors report, and how the plugin you can install differs from the system that produced the numbers. Every result below is the authors’ own; GenAI Brief has not run TokenEconomizer.

Who built it and what was published

The paper, “TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents”, was posted to arXiv as version 1 on 15 October 2026. It has 11 authors from three groups: UC Berkeley (including Ion Stoica and Bin Yu), Microsoft Research (including Jianfeng Gao and Michel Galley) and Microsoft Security. The first author, Aaron J. Li of UC Berkeley, did the work during an internship at Microsoft Research, according to the paper’s footnote.

The GitHub repository microsoft/TokenEconomizer was created on 13 October 2026 and had about 7,460 stars when we checked its metadata on 18 November. Its LICENSE file is the MIT licence, although a badge in the README says Apache 2.0; anyone with a licensing policy should read the file. Independent coverage followed the paper: MarkTechPost reported it on 30 October with figures that match the paper. The Microsoft Research blog of 16 November is a summary for a wider audience, not a new result.

Where a coding agent’s tokens go

The starting point is how agents are billed. On every turn, an agent sends its model the system and harness instructions, the description of every loaded tool, and the history of the session so far. The paper’s first figure shows the consequence: the billed context grows each turn, and “earlier content” is “charged repeatedly across the trajectory.” Prompt caching discounts that replayed context but, as the authors put it, “does not eliminate its cost.” Our prompt caching explainer covers how those discounts work at the main providers.

The authors argue that token efficiency is usually measured one task at a time, while developers use agents “to continuously build, update, and maintain large-scale projects.” So they profiled the unmodified agent across sequences of tasks in the same repository. The profiling run used Claude Code with Opus 4.8 at high reasoning effort on 60 tasks from SWE-Bench Verified, ten from each of six Python repositories (scikit-learn, SymPy, Django, Sphinx, Matplotlib and xarray), run in order within each repository.

They found three recurring kinds of waste:

WasteWhat the profiling found
Rediscovering the same factsOnce at least five tasks preceded the current one, 30 per cent of tool calls repeated an action from an earlier task in the same repository, up from 14 per cent for the second and third tasks. Against another repository’s full history, only 7 per cent matched. Actions recurring in at least half a repository’s tasks accounted for 12 to 28 per cent of the bytes its tool calls sent and received.
Paying for unused toolsThe agent was shown 23 tool schemas on every turn. No repository used more than 7; 16 were never called, and 3 accounted for 98 per cent of all calls.
Getting stuck on failuresThe 10 failed tasks were 17 per cent of tasks but 32 per cent of spend. In Matplotlib, failures averaged 45 turns against 20 for successes; in Sphinx, 36 against 31.

Source: TokenEconomizer paper, section 2 and appendix B. The authors describe these as upper bounds on removable cost, not achievable savings.

The failure finding comes with a warning against the obvious fix. Repeated error signatures are common in runs that succeed too: 36 of the 50 successful runs repeated a failure signature, and “more than half of the spend after a repetition falls in runs that go on to succeed.” A fixed turn limit would kill recoverable runs. The authors conclude that a guard “must therefore separate persistent loops from recoverable ones” and “should redirect before it terminates.”

Why one fixed strategy is not enough

The authors also tested three popular open-source cost-saving tools on the same 60 tasks, each with one configuration for every repository. Rust Token Killer (RTK) compresses shell command output before the agent sees it. Serena adds symbol-level code navigation through an MCP server backed by language servers. Aider’s repository map adds up to 2,048 tokens of ranked file and symbol signatures to the instructions, where it is billed every turn.

RepositoryRTKSerenaRepoMap
scikit-learn−6.9%+28.6%+30.5%
SymPy+7.3%+30.8%+9.8%
Django−19.9%−15.4%−16.2%
Sphinx+0.6%+2.1%−7.5%
Matplotlib−4.9%−4.8%+5.0%
xarray−16.8%+4.7%−20.2%
All 60 tasks−6.7%+6.0%−4.7%

Cost change relative to default execution; negative is cheaper. Paper table 3 and project page.

Every tool helped somewhere and hurt somewhere else. All three cut cost on Django and raised it on SymPy. The authors’ conclusion is that cost control has to be learned per repository rather than configured once.

How TokenEconomizer works

TokenEconomizer treats the agent as a black box. The paper says it “acts through exposed prompt and tool settings, monitors execution events, and does not modify model weights or agent-loop code.” It keeps a state for each repository, built only from tasks already completed there, and before each new task it sets three policies: which micro-skills to add to the prompt, which tools to load, and a turn budget for the failure-loop guard. It can always leave the default in place by adding nothing, pruning nothing and never intervening.

The design rests on the controller’s objective: minimise mean cost per task, “including its own calls, while keeping success near default execution.” Every model call the controller makes is charged to the task that triggered it. That accounting is what makes the headline numbers net savings rather than gross ones.

Readers who want the general picture of the loop, tools and context around a model can start with our explainer on agent harnesses. TokenEconomizer is best understood as a second controller wrapped around the harness, adjusting what the harness sends.

Mechanism 1: micro-skills, one verified fact at a time

A micro-skill is a single operational fact about one repository: the test command that works, where sources live, a setup step that is unnecessary. The authors chose this granularity on purpose. Frontier agents “already solve most tasks”, they write, and much of their removable spend goes to “rediscovering the same environment facts from task to task” rather than to missing problem-solving ability.

The lifecycle has four steps:

  1. Propose. After task 4 and every five tasks after that, an LLM proposer reads compact digests of the repository’s eight most recent tasks (command templates, test invocations, edited file names, errors, no solution text) and drafts at most four candidate facts. Each comes with executable detectors: regular expressions or built-in checks that test the fact against later trajectories without a model call.
  2. Confirm. A candidate becomes active only after it has been confirmed on three tasks whose edited files do not overlap, so that the evidence reflects the repository rather than one module that keeps coming up.
  3. Check need. An active fact is injected only while its “need rate”, the share of relevant tasks that actually needed it, stays at or above 0.4 over at least four relevant tasks. A true fact that never prevents any waste is withheld, because it would add tokens to every turn.
  4. Retire. Each fact carries a support score that decays older evidence by a factor of 0.8 per task and counts one contradiction as five confirmations. When support drops below zero the fact is retired permanently. A fact marked high-stakes, such as a test or build command, retires at its first contradiction once confirmed.

The asymmetry is deliberate. A stale fact “is re-billed on every later prefix”, the paper says, while a fact retired too eagerly “can be proposed again under a new identifier.”

The appendix shows the mechanism working and failing. In one SymPy stream, in an environment that had no pytest, the controller learned that tests run through SymPy’s native runner, python -c "import sympy; sympy.test(...)". On a later task, the default agent spent 15 turns, including failed attempts with pytest; the controlled agent went straight to the native runner and finished in 11. In another SymPy stream, the proposer learned the opposite, wrong fact: that python -m pytest was the canonical command. Its confirming detector matched the command itself rather than a passing result, so failed attempts counted as confirmations and the fact was activated. The first task that received it hit ModuleNotFoundError, which matched the contradiction detector, and the fact was retired after one injection. That example is the authors’ own illustration of why the retirement rule exists.

Mechanism 2: tool pruning

Tool pruning removes tool schemas that the agent is unlikely to use. The core tools for shell execution and reading, writing and editing files are always kept. In the paper’s configuration, a tool is masked after three consecutive tasks leave it uncalled. An LLM judge also reviews each never-called tool against the task description, with links to the repository’s pull requests, issues and commits masked, and can mask it early. Every fifth task, the full catalogue is restored for a re-audit, and a tool called during a re-audit is never masked again.

The effect on the prompt is large because tool schemas are re-sent on every turn. In the paper’s Django example on Claude Code with Sonnet 5, the judge masked 19 tools from the second task onward, leaving Bash, Edit, Read and Write. The first request of each task fell from 42,000 to 46,000 prompt tokens to between 15,003 and 16,295. On GitHub Copilot CLI, 10 of 19 tools were masked and the first request fell from 25,000 to 26,000 tokens to between 10,066 and 11,347.

Each harness exposes pruning differently, and the paper documents the adapters. Claude Code takes masked tools through its disallowed-tools option, which removes their schemas from every request. Copilot CLI uses its excluded-tools option; the authors note its deny-tool option “would only refuse execution while still billing each schema on every turn.” Codex cannot remove tools one at a time, so the pruning unit there is a “capability package”, such as sub-agent collaboration or image input.

Mechanism 3: failure-loop intervention

The guard learns a turn budget for each repository from its own history: 1.25 times the 90th percentile of turn counts among previously successful tasks. That budget is a reference, not a stop. After each tool call, a rule-based check looks for repeated failure signatures, dense error output or a run past the budget, without a model call. When it fires, an LLM judge reads a digest of recent actions and decides whether the agent is stuck or still making progress. The judge’s prompt tells it to favour “sparing the agent” whenever there is any sign of progress.

A confident stuck verdict, at confidence 0.7 or higher, produces a short redirect written by a model that names the repetitive pattern and suggests a materially different approach. If the failure recurs and the judge again says stuck, the controller ends the run. A backstop the judge cannot veto stops a run at 2.5 times the budget, but only if a strict stall rule holds: heavy edit churn, at least six error outputs and repeated failure signatures at once.

The appendix gives one of each outcome. On a Sphinx task, the default agent made 18 edits to one file and passed after 42 turns. Under the guard, the agent had made 11 edits with no test run and the same failure three times when the judge flagged it as stuck at confidence 0.72; after the redirect it re-read the failing test, ran it and passed in 31 turns. On an xarray task that the default agent also failed, the forced stop ended the run seven turns sooner than default.

The shared configuration

SettingPaper value
Micro-skill proposer cadenceEvery 5 tasks
Confirmation3 confirmations on tasks with non-overlapping edited files
Need gateRate of at least 0.4 over at least 4 exercised tasks
Support decay and contradiction weight0.8 and 5
Tool removalUnused for 3 tasks, plus a per-task judge
Tool recoveryFull catalogue every 5 tasks
Turn budget1.25 times the 90th percentile of passed turns
Stuck detectionLLM judge, confidence 0.7
Redirects1, then stop
Forced stop2.5 times the budget, if the strict stall rule holds

Paper table 4. One configuration served all three harnesses and four benchmarks, changed only where a benchmark’s stream structure required it (a starting turn budget on Web-Bench, micro-skills off for the security benchmarks); values were fixed before the main runs, during development on the same six SWE-Bench repositories.

That last detail is a limitation worth keeping in mind. The hyperparameters were not tuned per repository, but they were set in “earlier development runs on the same six SWE-Bench repositories” used for the main results.

The experiments and their conditions

The main evaluation ran five agent and model settings on the same 277 SWE-Bench tasks: Claude Code with Sonnet 5, Claude Code with Opus 4.8, Copilot CLI with Sonnet 5, and Codex with GPT-5.6 Terra and with GPT-5.6 Sol. The harness versions were Claude Code 2.1.170, Codex 0.153.1 and GitHub Copilot CLI 1.0.84-7.

The task set mixes 199 SWE-Bench Verified tasks with 78 harder tasks from the full SWE-Bench test split, because with Verified tasks alone “nearly every method passes nearly every task” in scikit-learn and SymPy. The authors checked every added task by applying its gold patch in the official image and running the official evaluation. The per-repository counts are scikit-learn 60, SymPy 60, Django 40, Sphinx 44, Matplotlib 34 and xarray 39. Within each repository, tasks run in base-commit order, so the controller only learns from earlier work, and every repository starts with no history.

Three further benchmarks test transfer: 102 tasks from five sequential Web-Bench projects, where each task builds on the previous one’s workspace, and 100 tasks each from CredData (finding credentials) and ReposVul (finding vulnerable lines), where every task is a different repository under one audit prompt.

Two conditions shape how far the numbers travel:

  • Default is high effort. “In every setting, default execution is the unmodified agent at high reasoning effort, with no external control.” Savings are relative to that.
  • Cost is relative and cache-aware. The metric charges uncached input, cache reads and output at their applicable prices, using provider-reported token classes, plus every auxiliary controller call. Results are reported as paired percentage changes against default, with standard deviations across three seeds, not as dollar amounts.

The authors also blocked a shortcut. Because SWE-Bench fix commits and Web-Bench grading specifications are public on GitHub, every method, including default, ran behind an “answer-key guard” that made GitHub unreachable from the task container. On Codex 0.153.1, the second layer of that guard, a shell hook, “did not invoke it in our tests”, so Codex relied on network blocking alone.

What the results show

SWE-Bench: cost against pass rate

SettingTokenEconomizer: cost changePass@1, default to TEMedium effort: cost changePass@1 at mediumLow effort: cost changePass@1 at low
Claude Code, Sonnet 5−23.6%74.7 → 76.0−26.6%70.0−45.5%65.1
Claude Code, Opus 4.8−30.9%74.0 → 73.0−16.8%72.2−31.0%70.4
Codex, GPT-5.6 Terra−24.7%73.8 → 74.7−25.7%69.6−33.0%65.3
Codex, GPT-5.6 Sol−26.1%80.1 → 81.7−28.9%76.7−43.9%69.8
Copilot CLI, Sonnet 5−18.4%75.0 → 77.6−25.4%72.6−41.9%65.9

Paper table 1. Cost is the paired change from high-effort default and includes controller overhead. Pass@1 in per cent. Three seeds per setting; standard deviations are mostly between 0.4 and 2.4.

Read across a row, and the shape of the trade-off is clear. Medium effort saves about as much as TokenEconomizer in most settings, and low effort saves more, but both lose pass rate in every setting. TokenEconomizer’s pass rate stays within 2.6 points of default and falls in only one setting, by 1.0 point. On Claude Code with Opus 4.8, TokenEconomizer saved 30.9 per cent at a 1.0-point loss, where medium effort saved 16.8 per cent at a 1.8-point loss.

Some of the Pass@1 gains are close to the seed-to-seed noise. Sonnet 5 on Claude Code moves from 74.7 (standard deviation 1.3) to 76.0 (1.2), for example. The authors’ summary, “comparable task success”, is the fairer description than “better”, and we would not read the four gains as evidence that the controller makes agents more accurate.

The paper also tested combinations. Adding RTK on Claude Code with Opus 4.8 raised the saving from 30.9 to 33.2 per cent with Pass@1 above default. Combining with RepoMap saved less than TokenEconomizer alone in four of five settings, because the map is billed every turn. The authors’ explanation is that the fixed tools supply different information: micro-skills say how to operate in a repository, while a repository map helps with where a fix belongs.

Consistency across repositories

Pooled averages can hide cost increases in individual repositories, which is exactly what happened with the fixed strategies. Across the 30 combinations of repository and setting, TokenEconomizer reduced cost in all 30, by 5.2 to 40.1 per cent. RTK alone raised cost in 12 of the 30, and RepoMap alone in 15.

Savings take a few tasks to arrive

Because each repository starts with no history, the controller can cost more at first. Averaged over the two Claude Code settings, “All repositories except xarray initially cost more” under TokenEconomizer, but “all become cheaper by the sixth task and remain cheaper thereafter”, ending with cumulative savings of 16.9 to 32.0 per cent. For a developer, that means the plugin is a poor fit for a repository touched a handful of times and a better one for a codebase worked in daily.

Which mechanism does the work

Variant (Claude Code)Sonnet 5: costSonnet 5: Pass@1Opus 4.8: costOpus 4.8: Pass@1
Defaultbaseline74.7baseline74.0
Micro-skills only−11.8%77.3−14.3%74.2
Tool pruning only−13.2%74.3−17.7%73.5
Failure-loop guard only−7.1%76.2−5.4%72.6
All three−23.6%76.0−30.9%73.0

Paper table 2a.

Tool pruning carries the largest single share, the authors say, “because it acts on every turn of every task.” Micro-skills are close behind. The guard contributes single digits. None alone reaches the combined saving, and no variant moved Pass@1 more than three points from default. The activity counts in the appendix show how selective the guard is: the judge is consulted 10 to 13 times per stream, but redirects follow on roughly one task in ten and aborts on fewer than one in twenty. About one in five proposed micro-skills is retired within its stream.

Beyond SWE-Bench

WorkloadAgentCost changeQuality, default to TE
Web-Bench (Pass@2)Claude Code−21.2%69.3 → 73.3
Web-Bench (Pass@2)Codex−16.0%64.0 → 66.5
Web-Bench (Pass@2)Copilot CLI−18.7%60.8 → 59.3
CredData (F1)Claude Code−19.6%67.9 → 70.1
CredData (F1)Codex−16.5%68.0 → 69.2
CredData (F1)Copilot CLI−18.3%68.2 → 67.7
ReposVul (F1)Claude Code−7.5%17.5 → 19.6
ReposVul (F1)Codex−6.4%19.4 → 20.1
ReposVul (F1)Copilot CLI−9.3%21.6 → 22.5

Paper table 2b. Claude Code averages Sonnet 5 and Opus 4.8.

The security results test a harder case. Every task is a new repository, so repository-specific micro-skills have nothing to carry forward and were switched off; only pruning and the guard ran. CredData still saved 16.5 to 19.6 per cent, which suggests the remaining mechanisms learn the audit procedure rather than the codebase. ReposVul saved much less, because “shorter trajectories leave less removable cost.” The ReposVul F1 scores are low in absolute terms because the authors grade strictly at the line level: naming the right function but a different line scores zero.

Trade-offs the authors report

The paper is specific about what can go wrong, and pairs each risk with a recovery path.

Each mechanism can make a wrong call. “A micro-skill may become stale, a pruned tool may become necessary, and a difficult but productive task may be mistaken for a failure loop.” The recoveries are retirement on contradiction, re-audits that restore tools, and a guard that redirects before it stops and spares uncertain cases. The pytest example shows the first recovery working after one bad injection; it also shows that a badly written detector can activate a false fact in the first place.

Warm-up costs money. In most repositories the controller cost more than default for the first few tasks.

The benchmark streams are not real sessions. “Our SWE-Bench streams consist of related but independent fixes rather than actual user sessions.” Each task starts from a fresh checkout of its own base commit, and each stream spans 1.9 to 8.5 years of the repository’s history, over which layouts, test commands and dependencies drift. The authors call this “a conservative test of experience reuse” and expect continuous sessions to offer more reusable experience. That is a reasonable argument, but it is an expectation, not a measurement. Web-Bench, where tasks inherit the workspace, is the closest test, with streams of only 20 or 21 tasks.

Success signals come from graders. The turn budget uses the benchmark grader’s pass or fail. “In realistic settings any comparable success signal can be used,” the paper says, but a developer’s machine does not have a grader, which is one reason the plugin defines success differently (see below).

Coverage of harnesses. The experiments cover three widely used agents but “not more minimal harnesses such as Pi”. The authors add that supporting one needs “an adapter rather than new meta-strategies”.

Combinations trade savings for quality. Adding fixed strategies sometimes lifted pass rate but usually lowered the saving: RTK by up to 5.2 points outside Opus 4.8, and RepoMap in four of five settings; “which combination is preferable depends on the setting.”

To those we would add two points of our own. First, the cost figures are relative changes computed at applicable provider prices with three seeds, not measured invoices; a team on a flat subscription will see the saving as more work within its plan rather than a smaller bill. Second, the evaluation is on Python repositories for SWE-Bench, plus JavaScript and Node projects for Web-Bench; the README says micro-skills work “in any language”, but the paper’s evidence base is narrower.

The plugin is not the paper’s configuration

The open-source plugin is what most readers will install, and its README describes defaults and behaviour that differ from the experiments. That is not a hidden discrepancy; the README documents each setting. But it means the paper’s numbers describe a configuration you do not get out of the box.

BehaviourPaper experimentsPlugin defaults (README, read 18 November 2026)
Unit of learningOne benchmark task per sessionReal sessions and turns (a turn is the agent’s work on one prompt)
Micro-skillsOn; proposer every 5 tasksOff by default “because its proposer adds model calls”; when on, proposer every 3 sessions, and facts also learned from repeated failures
Fact activation3 confirmations on non-overlapping edits, need gate 0.4Stated “once three sessions have confirmed it”, dropped when contradicted
Tool pruning triggerUnused for 3 tasks, plus LLM judge per taskUnused over 10 prompts spanning at least 2 sessions, or over 5 sessions; no model call with default settings
Tool recoveryFull catalogue every 5 tasksOne command, toolprune restore; restored tools are not removed again
When pruning appliesBefore each taskDeny list written only after 60 idle minutes in the repository, or at the latest a day after it forms
Loop guard warm-upBudget from passed tasks (grader)Waits for 5 turns that “ended well”, with no failing check after the last edit
Loop guard actionRedirect once, then stop the runRedirect once, then tell the developer how to stop it; “it never stops a turn itself”
BackstopForced stop at 2.5 times the budgetRedirect without the judge at 2.5 times usual length

The pruning delay is a thoughtful detail. The README explains that “a conversation resumed after its tools change must write its whole history to the prompt cache again instead of reading it”, so changing the tool list mid-session can cost more than it saves. Waiting for an idle hour, after which the cache “has expired anyway”, avoids that.

The never-stop rule changes the trade-off for unattended runs. The README notes that “In a headless run nobody may be watching, so a flagged turn runs until it ends or reaches the agent’s own limits.” The paper’s forced stop saved tokens on tasks that were going to fail; the plugin’s default leaves that saving on the table in exchange for never killing a developer’s work.

Practical constraints also apply. Python 3.10 or newer must be on PATH. The plugin’s model calls run “through your own agent, on the same plan or login”, so it needs no API key of its own, and what it learns stays in ~/.tokeneconomizer. Supported host versions are pinned: Claude Code 2.1.300 to 2.1.310, Codex 0.153.1 to 0.164.0 and Copilot CLI 1.0.83 to 1.0.102, with older versions of those three “not supported”, and Pi 1.2.0 to 1.3.0. The paper’s Claude Code runs used 2.1.170, which falls outside the plugin’s supported Claude Code range. On the experimental hosts (opencode, Cursor Agent, Grok Build, Hermes Agent, the Antigravity CLI and Factory Droid), tool pruning is not available, and on Claude Code the pruning applies by writing to .claude/settings.local.json; a settings file the plugin creates is kept out of git.

What a team should take from it

For a team that runs coding agents in the same repositories every day, the paper’s diagnosis is useful even without the plugin, because two of the three wastes can be checked by hand.

  1. Count your loaded tools. In the profiled setup, 16 of 23 tool schemas were never used, and pruning them cut first-request prompts by more than half in the Django example. Most harnesses let you disable tools per project. If you pay per token, check what you load on every turn. Our Claude Code pricing guide covers how plan limits and per-token billing interact.
  2. Write down the facts your agent keeps rediscovering. The micro-skill idea is a disciplined version of a project instruction file, with two rules worth copying: keep each entry to one verifiable fact, and delete it when it stops being true. The paper cites work finding that indiscriminate repository context “can increase cost without generally improving success”.
  3. Measure before trusting the headline. The 18.4 to 30.9 per cent range is for high-effort default runs on SWE-Bench task streams. Before adopting the plugin, record a baseline of cost per task and success on your own repositories for a week, then compare. The README’s status command reports what the plugin did and what sessions cost.
  4. Decide on micro-skills deliberately. They are off by default in the plugin, and on their own they saved about half as much as the full system in the paper. Turning them on adds proposer calls; the envfacts mode learns facts only from repeated failures, with no model calls.
  5. Expect a warm-up. Judge the plugin after at least half a dozen sessions in a repository, not after the first.
  6. Do not switch effort down and assume the same result. The paper’s clearest finding is that effort reduction and experience-based control land in different places on the cost and quality trade-off.

TokenEconomizer’s contribution is less the 30 per cent figure than the argument behind it: a coding agent’s cost is partly a property of the repository, and the agent’s own logs already contain what it needs to stop paying for the same lessons twice. The paper supports that argument on benchmark streams. Whether it holds in daily use, with the plugin’s more cautious defaults, is a question each team can now test on its own code.

Sources

  1. TokenEconomizer: Learning from experience to make AI coding agents more efficient Microsoft Research
  2. TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents (arXiv:2610.22732) Li and colleagues, arXiv
  3. TokenEconomizer publication page Microsoft Research
  4. microsoft/TokenEconomizer repository and README GitHub
  5. TokenEconomizer project page TokenEconomizer authors
  6. SWE-bench: Can Language Models Resolve Real-World GitHub Issues? Jimenez and colleagues, arXiv
  7. Web-Bench: A LLM Code Benchmark Based on Web Standards and Frameworks Xu and colleagues, arXiv
  8. Rust Token Killer (RTK) GitHub
  9. Serena GitHub
  10. Aider repository map Aider
  11. Meet TokenEconomizer: Microsoft's plugin that cuts coding agent costs by up to 30.9% MarkTechPost

Frequently asked questions

What is TokenEconomizer?

An open-source plugin and research system from UC Berkeley, Microsoft Research and Microsoft Security that reduces the token cost of coding agents such as Claude Code, Codex and GitHub Copilot CLI. It learns from completed sessions in a repository and acts only through the agent's prompt, tool settings and event stream, without changing the agent or the model.

How much does TokenEconomizer save?

In the authors' experiments on 277 SWE-Bench tasks, mean cost per task fell by 18.4 to 30.9 per cent across five agent and model pairs, including the cost of the controller's own model calls. On sequential web development (Web-Bench) costs fell 16.0 to 21.2 per cent, and on two security-auditing benchmarks 6.4 to 19.6 per cent. These are the authors' results; GenAI Brief has not run its own tests.

Does TokenEconomizer make the agent worse at fixing bugs?

Not in the paper's SWE-Bench results. Pass@1 rose in four of the five agent and model pairs and fell by 1.0 point for Claude Code with Opus 4.8. Several of the differences are close to the reported standard deviations across three seeds, so the fairest summary is the authors' own: comparable task success.

How is it different from lowering reasoning effort?

Lowering effort makes every turn cheaper by thinking less, and in the paper it cut Pass@1 by 1.8 to 10.3 points. TokenEconomizer keeps the model and effort at their default and removes cost that repeats across tasks in the same repository: rediscovered facts, tool descriptions that are never used and long failing loops.

Does TokenEconomizer need its own API key?

No. The README says the plugin needs no API key of its own; its model calls, such as the loop guard's judge, run through the user's own agent on the same plan or login, and their cost is included in its reports. What it learns is stored locally in ~/.tokeneconomizer.

Which coding agents does the plugin support?

The README lists Claude Code, Codex, GitHub Copilot CLI and Pi as supported, with experimental support for opencode, Cursor Agent, Grok Build, Hermes Agent, the Antigravity CLI and Factory Droid. Supported versions are pinned, for example Claude Code 2.1.300 to 2.1.310, and tool pruning is not available on any of the experimental hosts.

All research →