TokenEconomizer: Microsoft's Plugin for Claude Code, Codex, and Copilot CLI That Cut Context by 31 Percent ✅ yoDEV Tested

TokenEconomizer, the Microsoft Research and UC Berkeley plugin for Claude Code, Codex, GitHub Copilot CLI, and Pi, cut 31 percent of the context from each Claude Code request in our test, without losing any tasks. It doesn’t work from the first session: it needs several sessions in the same repository before it starts saving.

:white_check_mark: yoDEV Tested · October 23, 2026
We ran 32 sessions of Claude Code 2.1.305 with Sonnet, with and without TokenEconomizer (commit 0ce0e06), on 8 consecutive tasks in the same Python repository, repeated twice. The results we report as ours come from that test.

What is TokenEconomizer and how does it save tokens?

It’s a plugin that doesn’t touch your agent and makes subsequent sessions in the same repository cheaper. In each turn, a programming agent re-charges its instructions, all loaded tools, and the conversation up to that point. The plugin reads each completed session and changes what the following sessions pay through three mechanisms:

  • Micro-skills. Environment data that your sessions rediscover by failing over and over (for example, that pytest isn’t installed but python -m pytest does work) are learned and indicated at the start of the next session. Learning them doesn’t consume any model calls.
  • Tool pruning. Tools that are still loaded but nobody uses, by default across five consecutive sessions, are left out of the following sessions through the agent’s own configuration.
  • Loop guard. A turn that repeats the same failed cycle of editing and testing gets a redirect. If it stays stuck, the plugin tells you how to stop it. It never stops a turn on its own.

It uses only Python’s standard library, doesn’t need its own API key, and works with the plan or login your agent already uses. What it learns is saved in ~/.tokeneconomizer. Apache 2.0 license.

How much does it save according to Microsoft’s paper?

The paper (arXiv 2610.22732, published October 15, 2026) reports an average cost between 18.4 and 30.9 percent lower on SWE-Bench, with five agent and model combinations. The authors measure accounting for prompt caching and include the plugin’s own calls:

Agent and model Average cost reduction
Claude Code + Opus 4.8 30.9%
Codex + GPT-5.6 Sol 26.1%
Codex + GPT-5.6 Terra 24.7%
Claude Code + Sonnet 5 23.6%
Copilot CLI + Sonnet 5 18.4%

According to the paper, Pass@1 went up in 4 of the 5 combinations. These are figures from the authors themselves, measured on 277 tasks across six repositories, with each repository’s tasks in sequence: a much longer streak than a normal week of work.

How much did it save in our test with Claude Code?

We set up a small Python repository with two traps that each session has to rediscover: imports only work with PYTHONPATH=src, and the package refuses to load if STORE_ENV isn’t defined. We didn’t document either one, on purpose. Then we gave Claude Code 8 consecutive bug reports, with and without the plugin, twice.

Without plugin With plugin
Tasks solved 16/16 16/16
Context per request, before the plugin acted 24,779 tokens 24,809 tokens
Context per request, with pruning active 25,966 tokens 17,795 tokens (−31%)
Cost of sessions with pruning active $0.72 $0.61 (−15%)

What each mechanism did:

  • Tool pruning acted, and its effect was clear. It kicked in on session 8 of the first run and session 6 of the second. It left out 284 tools: most were from connectors that load in each session of our configuration (Docs, Discourse, Drive), plus 16 Claude Code-specific tools we never used, like scheduled tasks and worktrees. From then on, each request carried about 8,000 fewer tokens.
  • Micro-skills didn’t activate. The plugin did detect that our sessions were failing with python -m pytest. But data only forms after three sessions confirming it among at least four where it applies, and Claude didn’t fail in the same way consistently enough. After 8 sessions, the best candidate was at 2 of 7.
  • The loop guard didn’t intervene. No turn got stuck: the tasks were short.

The plugin’s own cost was zero. Across 32 sessions, the plugin side cost 8.5 percent less, but most of that came from sessions where nothing had changed yet. That part is normal variation between runs, so we didn’t count it as a plugin effect. The 4 sessions with active pruning are a small sample; the solid data is the context drop.

We changed one setting from the defaults. Normally, pruning waits for your sessions to be inactive for an hour before writing the excluded tools list, to avoid breaking a prompt cache that’s still hot. Our sessions ran one after another, so we used toolprune_quiet_minutes=0.

Is it worth it if you use many MCP servers in Claude Code?

Yes: it’s the case where it saves the most. The savings depend on two things:

  • How many tools load in each session. If you have many MCP servers or connectors, pruning has a lot to cut. With a minimal configuration, there’s little to trim.
  • How many sessions you do in the same repository. Data forms from repeated evidence, so the plugin pays off on code you work with daily, not one-off repos. If your repository already documents its quirks in a CLAUDE.md, micro-skills have less to learn.

If you want to cut tokens other ways, here we tested how to do it with hooks, and here how to see token consumption in Codex CLI.

Is it free and how much does Claude Code’s price drop?

The plugin is free and open source, and makes no model calls on its own: its paid helpers (an LLM-powered data generator and a judge for the loop guard) come off unless you turn on paid=true. What drops is what you pay per session of your agent: in our test, 15 percent in sessions with active pruning, at API list prices. With a subscription plan, the effect is that the same quota gets you more work.

How to install the plugin on Claude Code, Codex, and Copilot CLI?

You need Python 3.10 or higher in your PATH. Clone the repository into a folder where it will stay, because agents run the plugin from there:

Claude Code

git clone https://github.com/microsoft/TokenEconomizer.git
claude plugin marketplace add "$PWD/TokenEconomizer"
claude plugin install tokeneconomizer@tokeneconomizer

Start claude in a repository and run /tokeneconomizer:status. Once per machine, and again each time Claude Code updates, run /tokeneconomizer:toolprune refresh-catalog: it registers what tools a session loads, and without this step pruning only sees a few.

Codex

codex plugin marketplace add "$PWD/TokenEconomizer"
codex plugin add tokeneconomizer@tokeneconomizer

When Codex shows Hooks need review, choose Trust all and continue.

Copilot CLI

copilot plugin marketplace add "$PWD/TokenEconomizer"
copilot plugin install tokeneconomizer@tokeneconomizer

The marketplace path needs to be absolute. Supported versions per the README: Claude Code from 2.1.300 to 2.1.307, Codex from 0.153.1 to 0.163.0, and Copilot CLI from 1.0.83 to 1.0.102. At the time of publishing this note, the authors hadn’t checked later versions.

How to see what it did or undo the changes?

From a terminal, inside the repository and without spending tokens:

~/.tokeneconomizer/bin/te status              # what it learned and how much your sessions cost
~/.tokeneconomizer/bin/te toolprune           # what tools it left out and why
~/.tokeneconomizer/bin/te toolprune restore   # put them back

By default, pruning applies without asking you, and in Claude Code the notice only shows up in the detailed transcript (Ctrl+O). If you’d rather approve each list yourself, run te config set toolprune=propose. For a single session without the plugin, start the agent with TE_DISABLE=1 claude.


How about you? How many MCP servers do you have connected today in your programming agent?

What do you think spends the most tokens on your agent?
  • Tools and MCP servers that load in each session
  • Re-explaining the project in each new session
  • Turns that get stuck retrying the same thing
  • I prefer another option (tell us which)
0 votantes

Comment below or, if this article reached you by email, reply directly to the email: your reply gets published here.

Related: How to reduce your AI agent’s token consumption: we tested Pensieve on a real repo