Meet TokenEconomizer: Microsoft’s Plugin That Cuts Coding Agent Costs by Up to 30.9%

A team from Microsoft Research and UC Berkeley has released TokenEconomizer, an open-source plugin designed to reduce the token costs of coding…

By Vane October 30, 2026 4 min read

A team from Microsoft Research and UC Berkeley has released TokenEconomizer, an open-source plugin designed to reduce the token costs of coding agents by up to 30.9%. The tool learns from past sessions within a code repository to identify and eliminate waste in subsequent tasks. It functions alongside Claude Code, Codex, GitHub Copilot CLI, and Pi without altering model weights or the underlying agent code. Testing across 277 SWE-Bench tasks showed mean cost reductions ranging from 18.4% to 30.9% across five different agent-model configurations.

What it is

TokenEconomizer arrives as a standard-library Python package with three switchable mechanisms. It runs on any machine supporting the four listed agents provided Python 3.10 or newer is installed. The plugin requires no GPU and does not hold its own API key. Performance data indicates lower mean costs on all 30 repository-setting cells tested. The strongest result was a 30.9% reduction on Claude Code with Opus 4.8, rising to 33.2% when combined with RTK. Conversely, savings on ReposVul audits were modest, falling between 6.4% and 9.3%, while Pass@1 scores dropped by 1.0 point on Opus 4.8.

Where tokens get wasted

Every agent turn re-bills the system prompt, every loaded tool schema, and the full history. The researchers profiled 60 SWE-Bench tasks across six repositories using Claude Code with Opus 4.8 to identify three recurring sources of inefficiency. Once five tasks precede the current one, 30% of tool calls repeat an earlier action. Additionally, 23 tool schemas load every turn, yet 16 are never called and only three cover 98% of actual usage. Finally, 10 failed runs accounted for 17% of tasks but consumed 32% of total spend. Previous attempts to fix this with fixed open-source strategies like RTK, Serena, and Aider’s RepoMap failed to cut costs universally, often raising expenses on specific projects like SymPy.

How the controller functions

TokenEconomizer acts as an external controller treating the agent as a black box. It maintains a state per repository built from completed traces. Before each task, it sets three policies via the prompt, tool settings, and event stream.

Micro-skills

An LLM proposer converts trace digests into one-line facts, such as the working test command. Each fact carries regex detectors that check later traces without triggering a new model call. A fact enters the prompt after three confirmations on tasks with non-overlapping edited files. Its need rate must also stay at or above 0.4. One contradiction counts as five confirmations, ensuring incorrect facts retire quickly.

Tool pruning

Shell, read, write and edit tools remain active. Other tools are masked after three consecutive unused tasks or when an LLM judge marks them irrelevant. The full catalog returns every five tasks for a re-audit. On Django with Claude Code, the first request on task 2 fell from 43,351 to 16,295 prompt tokens.

Failure-loop intervention

The controller learns a turn budget set at 1.25 times the 90th percentile of successful run lengths. Cheap rule checks flag repeated failures or dense errors. An LLM judge then decides if the agent is stuck at 0.7 confidence or higher. A stuck agent receives one redirect, then a stop if the loop recurs.

Performance on SWE-Bench

SettingCost vs defaultPass@1 defaultPass@1 TokenEconomizer
Claude Code + Sonnet 5-23.6%74.776.0
Claude Code + Opus 4.8-30.9%74.073.0
Codex + GPT-5.6 Terra-24.7%73.874.7
Codex + GPT-5.6 Sol-26.1%80.181.7
Copilot CLI + Sonnet 5-18.4%75.077.6

Source: arXiv 2610.22732, Table 1. Costs include all controller calls. Three seeds per setting were used. Pass@1 improved in four of five settings. Lower reasoning effort saved cost but cut Pass@1 by 1.8 to 10.3 points. RTK alone raised cost in 12 of 30 repository-setting cells, and RepoMap in 15. Savings build over time. Most repositories cost more at first, but all were cheaper by the sixth task. Alone on Claude Code, tool pruning saved 13.2% to 17.7%, micro-skills 11.8% to 14.3%, and the loop guard 5.4% to 7.1%. Results also held outside SWE-Bench. Costs fell 16.0% to 21.2% on Web-Bench and 16.5% to 19.6% on CredData. ReposVul saw only 6.4% to 9.3%, because shorter runs leave less to remove.

Comparison with other tools

FeatureTokenEconomizerRTKSerenaAider RepoMap
ApproachLearns per-repository policies from past sessionsCompresses shell command outputMCP server with symbol-level code toolsRanked map of repository symbols in the prompt
Learns from earlier tasksYesNoNoNo
LicenseApache 2.0Apache 2.0 CLI; BUSL-1.1 engineGPL-3.0-or-later (MIT for SolidLSP)Apache 2.0
AgentsClaude Code, Codex, Copilot CLI, Pi18 AI coding toolsAny MCP clientAider
Mean SWE-Bench cost change (paper, 5 settings)-18.4% to -30.9%-8.9% to +4.5%Not in main runs (raised pooled cost in profiling)-6.1% to +6.5%
Cells with higher cost (of 30)012Not disclosed15

Cost rows derive from the TokenEconomizer paper. Licenses and claims come from each project’s repository or documentation.

Installation

The plugin needs one of the four agents and Python 3.10 or newer. On Claude Code, clone the repo, add it as a marketplace, then run `claude plugin install tokeneconomizer@tokeneconomizer`. Learned data stays local in `~/.tokeneconomizer`. Tool pruning and the loop guard are on by default. Micro-skills are off by default, because the proposer adds model calls.

Scroll to Top