Verdict: install TokenEconomizer if you run the same AI coding agent on the same repository most days - it cut billed cost 18.4 to 30.9 percent across five agent-model combinations in the paper's SWE-Bench measurements, and task success went up in four of those five combinations. Skip it for single-session work, where savings shrink to 6-20 percent. TokenEconomizer is an open-source plugin from Microsoft Research, Microsoft Security and UC Berkeley that makes agents like Claude Code and Codex cheaper to run without touching the model, weights or agent code. It is the top trending Python repository on Trendshift as of today, November 16, 2026.

TL;DR

Fact Detail
What it is A free Apache-2.0 plugin for Claude Code, Codex, the Copilot CLI and Pi that learns your repository from past sessions and cuts waste (GitHub, arXiv)
How Micro-skills remember verified repo facts; tool pruning drops unused tool definitions; a loop guard redirects a stuck agent once (GitHub)
Results 18.4-30.9 percent lower mean cost on 277 SWE-Bench tasks, cheaper in all 30 repository-model cells (GitHub)
Footprint Python 3.10+, no API key, no credential handling, everything learned stays on your machine (GitHub)
Caveat The plugin's own model calls run on your existing agent plan and are counted in its reported savings (GitHub)

What happened today

The repository, first created October 13, 2026 and now at 6,457 stars, ships the full plugin and paper under the name "TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents" (GitHub). Third-party write-ups landed today too: IFAI published on November 16, 2026 that Microsoft open-sourced TokenEconomizer to cut costs by up to 30.9 percent, following Marktechpost in late October. The team pairs UC Berkeley's Bin Yu and Ion Stoica with Microsoft Research's conversational-AI group and Microsoft Security (arXiv).

Why coding agents waste tokens in the first place

Agents are built to finish tasks, not to keep them cheap: every turn pays again for the instructions, every loaded tool and the conversation so far. Because developers run the same agent on the same repository repeatedly, most of that spend repeats - facts rediscovered from scratch, tools sent but never used, the same failing loops retried (GitHub). TokenEconomizer acts as an external supervisor: a black box that learns across sessions and pays back its own overhead over later sessions.

The three mechanisms, with defaults

Mechanism Trigger Action Reversible?
Micro-skills A fact confirmed across 3 sessions (or repeated failures) Injected into context at session start Dropped when contradicted
Tool pruning Unused over 10 prompts in 2+ sessions, or 5 sessions of any length Tool definition omitted via the agent's own settings One command restores it
Loop guard Judge model at minimum 0.7 confidence the turn is stuck Redirect note, at most once per turn It never stops the turn

Micro-skills capture the facts every session re-learns: the build step that must run first, the exact command that works here, an environment variable a script needs. A fact activates only after three sessions confirmed it, and a later contradiction removes it (GitHub).

Tool pruning exists because every loaded tool's definition rides on every request: leave a tool unused across 10 prompts spanning 2 or more sessions, or over 5 sessions of any length, and it is omitted until you restore it (GitHub).

The loop guard: when a turn keeps hitting the same failure, a judge model checks whether it is genuinely looping and, at 0.7 or higher confidence, adds one redirect suggesting another approach; if the turn is still stuck it tells you how to stop it rather than stopping anything itself (GitHub).

The numbers per agent-model combination

Combination Cost change Pass@1 change
Claude Code with Sonnet 5 23.6 percent lower +1.3
Claude Code with Opus 4.8 30.9 percent lower -1.0
Codex with GPT-5.6 Terra 24.7 percent lower +0.9
Codex with GPT-5.6 Sol 26.1 percent lower +1.6
Copilot CLI with Sonnet 5 18.4 percent lower +2.6

The paper ran all five combinations on the same 277 SWE-Bench tasks from six repositories, with costs at cache pricing and including every model call the plugin itself made (GitHub). Within individual repository-model pairs savings ranged from 5 to 40 percent, and the effect held outside the familiar-repository setting: Web-Bench fell 16-21 percent and two security-auditing benchmarks, where every task runs in a fresh repository, fell 6-20 percent (GitHub). Per-repository charts and nine annotated runs are on the project page.

Setup on Claude Code, four commands

  1. Clone the repository: git clone https://github.com/microsoft/TokenEconomizer.git (GitHub).
  2. Register the marketplace: claude plugin marketplace add "$PWD/TokenEconomizer" (GitHub).
  3. Install: claude plugin install tokeneconomizer@tokeneconomizer (GitHub).
  4. Start Claude Code in your repository, trust the folder, run /tokeneconomizer:status and allow its script; once per machine (and after Claude Code updates) run /tokeneconomizer:toolprune refresh-catalog (GitHub).

Codex and the Copilot CLI follow the same clone-add-install shape and Pi is built in; experimental adapters cover opencode, Cursor Agent, Grok Build, Hermes Agent, the Antigravity CLI and Factory Droid (GitHub). The package is standard-library-only Python - nothing to pip install - and agent billing is unchanged; Claude's team-tier pricing is covered in our Claude Team vs Pro India price comparison.

Verdict: who should install it, who should not

Install it when three conditions hold: one agent on one repository most days, spend large enough that a fifth to a third of it is real money, and savings that compound quietly instead of changing your workflow (GitHub). Settings ship as documented defaults, each mechanism switches off independently, and the plugin announces every action in one line.

Do not expect much from a single fresh session: the 6-20 percent security-audit savings are real but come mostly from the loop guard and tool pruning rather than repository memory (GitHub). Check the success trade-off too: four of five combinations improved Pass@1, but Claude Code with Opus 4.8 slipped 1.0 point while saving the most (GitHub). Teams with strict supply-chain policies should also weigh that it hooks into agent execution directly - the same trust decision tightening in our Codex CLI 0.169 untrusted folders update.

FAQ

Q: Does TokenEconomizer change my model, weights or agent code?
A: No. It is a black-box supervisor working through context the agent already reads and the agent's own settings - no retraining, fine-tuning or code changes (GitHub).

Q: What does it cost?
A: Free under Apache 2.0; its own model calls run through your existing agent plan and are counted inside its cost reports, so no new subscription or key is needed (GitHub).

Q: Does it work with Cursor or opencode?
A: Officially with Claude Code, Codex, the GitHub Copilot CLI and Pi; Cursor Agent, opencode, Grok Build, Hermes Agent, the Antigravity CLI and Factory Droid are supported experimentally (GitHub).

Q: What happens when a remembered fact turns out to be wrong?
A: Nothing catastrophic: a fact activates after three sessions confirmed it and any contradicting session drops it automatically (GitHub).

Q: Will it stop my agent when it gets stuck in a loop?
A: No. The loop guard injects one redirect per stuck turn at most, then tells you how to stop it; halting stays your call (GitHub).

Last verified: November 16, 2026. This article is AI-assisted; see our how we work policy. Related: Claude Code 2.1.321, OpenCode background subagents and Cursor Multiplayer Projects.