What is TokenEconomizer?
TokenEconomizer is a plugin that makes coding agents cheaper to run in the repositories you work in often, without changing the agent itself. It sits in the Context Compression & Token Budgets category of the App Orchestration tools and is open-source, written in Python and licensed Apache-2.0. To get started: clone and install the plugin.
Overview
TokenEconomizer is a plugin that makes coding agents cheaper to run in the repositories you work in often, without changing the agent itself. It comes from Microsoft Research, Microsoft Security and UC Berkeley, alongside the paper "TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents" (arXiv 2610.22732), and installs into Claude Code, Codex, the GitHub Copilot CLI and Pi, with experimental support for opencode.
The idea is that every turn of an agent pays again for its instructions, every loaded tool and the conversation so far — and developers run the same agent on the same repository over and over, so much of that cost repeats. TokenEconomizer reads the logs of the sessions an agent has already finished in a repository and uses that experience to cut waste in the sessions that follow, through three mechanisms: micro-skills (repository facts the agent keeps rediscovering, stated at session start), tool pruning (tools that go unused are left out of later sessions through the agent's own settings) and failure-loop intervention (a judge model checks whether a turn is stuck repeating the same failures and, if so, redirects it once).

Every action is designed to be reversible: facts that later sessions contradict are dropped, pruned tools come back with one command, and the loop guard only redirects and notifies — stopping a turn stays your call. The plugin's own model calls run through your agent on the same plan or login and are counted in its cost reports, and what it learns stays on your machine in `~/.tokeneconomizer`. In the paper's runs on 277 SWE-Bench tasks across five agent–model combinations, the authors report 18.4–30.9% lower mean cost, with Pass@1 up in four of the five combinations. The v0.1.0 release shipped in October 2026; the package is standard-library Python 3.10+ under the Apache-2.0 license.
What it does
- Micro-skills: learns repository facts (the build step that must run first, `python -m pytest` where `pytest` is missing, a required environment variable) from repeated failures and a periodic model review, and states them at session start once three sessions confirm them
- Tool pruning: tools left unused over a set number of prompts and sessions are excluded from later sessions through the agent's own settings, with `toolprune restore` to bring them back
- Failure-loop intervention: a judge model checks turns that keep hitting the same failures and redirects a stuck turn, then tells you how to stop it — it never stops a turn itself

- Works with Claude Code, Codex, the GitHub Copilot CLI and Pi, plus experimental opencode support, with the same command names on every agent
- Cost counted as billed, using cache pricing and including the plugin's own model calls, in a per-repository `status` report
- Each mechanism switchable per repository or globally, with tunable thresholds and a propose-only mode for tool pruning
Getting started
You need one of the supported agents, signed in any way it supports, and Python 3.10 or newer on PATH. The plugin needs no API key of its own. These steps follow the project README for Claude Code; Codex, the Copilot CLI, Pi and opencode have their own install lines there.
Clone and install the plugin
Claude Code runs the plugin from the clone, so keep it in place. Keep the marketplace path absolute.
git clone https://github.com/microsoft/TokenEconomizer.git
claude plugin marketplace add "$PWD/TokenEconomizer"
claude plugin install tokeneconomizer@tokeneconomizerCheck it is running
Start `claude` in one of your repositories, trust the folder, and run the status command, allowing its script if asked. It prints a short status block.
/tokeneconomizer:statusRecord the tool catalog
Once per machine, and again after Claude Code updates, record every tool a session loads so tool pruning can consider all of them. This makes no model call.
/tokeneconomizer:toolprune refresh-catalogWork as usual, then inspect what it did
The plugin needs nothing from you while you work. Its commands show what it learned and what your sessions cost; from a terminal in the repository the same commands run for free via `~/.tokeneconomizer/bin/te`.
/tokeneconomizer:status # what it learned and did here, and what sessions cost
/tokeneconomizer:microskills # the facts it injects, and those still forming
/tokeneconomizer:toolprune # the tools it left out, and the evidence
/tokeneconomizer:toolprune restoreTune or switch mechanisms
Tool pruning and the loop guard are on by default; micro-skills is off by default because its fact proposer adds model calls. Change settings with `config set`, or disable the plugin for one session with an environment variable.
/tokeneconomizer:config set microskills=on
/tokeneconomizer:config set toolprune_evidence=20
# one session without the plugin
TE_DISABLE=1 claudeCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Lower the bill of a coding agent you run day after day on the same repositories
- Stop an agent from re-learning the same build and test quirks at the start of every session
- Trim tool definitions a repository never uses from every request the agent sends
- Catch agent turns stuck in a loop of the same failing edits before they burn more tokens
How TokenEconomizer compares
TokenEconomizer alongside other open-source context compression & token budgets tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| RTK | ★ 85.3k | A single-binary Rust CLI proxy that filters, groups, truncates and dedupes the output of 100+ dev commands before a coding agent reads it, cutting token use by 60–90%. |
| Headroom | ★ 78.6k | Local context-compression layer that shrinks tool outputs, logs, files and RAG chunks before they reach the model, usable as a library, a drop-in proxy or an MCP server. |
| Context Mode | ★ 33.2k | An MCP server that keeps raw tool output out of the context window by sandboxing it, and indexes session events into SQLite FTS5 so an agent survives compaction. |
| TOON | ★ 25.6k | Token-Oriented Object Notation: a lossless, compact encoding of the JSON data model that declares row counts and field lists so tabular data costs fewer prompt tokens. |
| pxpipe | ★ 7.6k | A local proxy that renders bulky request context — system prompt, tool docs and older turns — as PNG pages the model reads with vision, cutting the input tokens a coding agent re-sends each turn. |
| TokenEconomizer | ★ 4.3k | A plugin that learns from past sessions to make coding agents cheaper in the repositories you use them in |
| LeanCTX | ★ 3.9k | Local context layer for coding agents with ten file read modes, 95+ shell-output compressors, reversible content-addressed recovery, session memory and a savings ledger. |
| CliffCompaction | ★ 71 | A transparent API proxy that trims a coding agent's history at a token threshold by truncating and dropping content only, never rewriting it, so summaries never stack on summaries. |
