TokenEconomizer

Experience-driven black-box cost control: a plugin that learns from your repository's past sessions to make coding agents like Claude Code, Codex and Copilot CLI cheaper without changing the agent.

Stars
★ 8k
Last updated
3d ago
FARS reviewed
Nov 01, 2026
License
MIT
Primary language
Python

At a glance

How it runs
Agent plugin / skillCLI
Works with
Portable with changesCodex · Claude Code
Cost
Free software; you pay for model usage
Setup effort
Low · running in minutes
You'll need
Python 3.10+Claude Code 2.1.300–2.1.329Codex 0.153.1–0.171.0Copilot CLI 1.0.83–1.0.114Pi 1.2.0–1.5.2Shell / CLINetwork accessLocal filesystem
Typical use
Individual developers running Claude Code or Codex daily on the same repositories who want measurably lower bills
Not a fit if
  • Users expecting identical full features across all coding agents: mechanism coverage differs per host
  • Teams running unsupported or untested versions of Codex, Copilot CLI, etc.
  • Users relying on tool pruning with hosts like Pi or Factory Droid that lack persistent tool settings
Maintenance
Commits in the last 30 dayslast commit 2026-11-20+131.9 ★/day over 7 days
Source review
64/100 · Some gaps

What does this agent do, and when should you use it?

TokenEconomizer is an open-source (MIT) plugin from Microsoft Research, Microsoft Security and UC Berkeley that makes coding agents cheaper to run in repositories you work in often, without touching the agent's model, weights or code. It has three mechanisms: micro-skills distills repository facts (like a working command such as python -m pytest) from finished sessions and injects them at session start; tool pruning drops tools that go unused across sessions through the agent's own settings files; and failure-loop intervention (the loop guard) has a judge model redirect turns that are stuck. It ships as a plugin for Claude Code, Codex, the GitHub Copilot CLI and Pi, with experimental support for opencode, Cursor Agent, Grok Build and others. In the paper's measurements across 277 SWE-Bench tasks, mean cost fell 18.4–30.9% across five agent–model combinations, cost was lower in all 30 repository × combination cells, and Pass@1 rose in 4 of 5. What it learns stays on your machine in ~/.tokeneconomizer, and its own model calls run through your logged-in agent with no separate API key.

The plugin uses each agent's hooks to read session logs (tokeneconomizer/trace normalizes every host's log into one shape) and updates all three mechanisms after each finished session. Micro-skills learns facts from failures that repeat across sessions and from a fact proposer that reviews recent sessions every k=3 sessions; a fact is injected at session start once three sessions confirm it and dropped when contradicted. Tool pruning counts tools unused over p=10 prompts spanning at least m=2 sessions, or s=5 sessions, and after q=60 idle minutes writes a deny list through the agent's own settings (Claude Code's .claude/settings.local.json, Codex's .codex/config.toml, Copilot CLI's MCP servers); toolprune restore gives tools back. The loop guard learns a per-repository envelope of usual turn length, sends turns showing repeated failures to a judge model (confidence c=0.7), and injects a redirect at most r=1 times per turn; if still stuck it tells you how to stop the turn and never stops one itself. You inspect and tune everything with status, microskills, toolprune, config commands (/tokeneconomizer:... in Claude Code, $tokeneconomizer:... in Codex, /te in Pi), and cost is computed with cache pricing including the plugin's own calls.

  1. Individual developers running Claude Code or Codex daily on the same repositories who want measurably lower bills
  2. Teams whose sessions keep rediscovering the same build steps, commands and environment variables and want that knowledge retained across sessions
  3. Copilot CLI users with many loaded MCP servers or tools but only a few actually used, so unused tool definitions stop riding on every request
  4. Automated repair pipelines where agents burn tokens in repeating failure loops and the loop guard can redirect in time
  5. Researchers who want to evaluate in read-only modes (toolprune=propose, microskills=envfacts) or rerun the paper's benchmarks via experiments/

Key setup facts

Pulled from the install and usage notes below. The project README has the current values.

Config files
~/.tokeneconomizer/bin/te
Runtime
Python 3.10+

How do you install or deploy this agent?

You need one of the supported agents, signed in any way it supports, and Python 3.10+ on PATH. The plugin needs no API key of its own.

Claude Code:

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

Codex:

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

Copilot CLI:

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

Pi:

pi install git:github.com/microsoft/TokenEconomizer

After installing, run once per machine (and again after Claude Code / Copilot CLI updates):

/tokeneconomizer:toolprune refresh-catalog

Experimental hosts (opencode, Cursor Agent, Grok Build, Hermes Agent, Antigravity CLI, Factory Droid) have separate install steps documented in the repo README and plugin/README.md.

How do you use this agent?

After installing, just work as usual. To see or change behavior, use the commands (same names everywhere, different typing): /tokeneconomizer:status or /tokeneconomizer:config set microskills=on in Claude Code / Copilot CLI, $tokeneconomizer:status in Codex, /te status in Pi, or from a terminal for opencode / Cursor / Grok / Hermes / Antigravity:

~/.tokeneconomizer/bin/te --host <host> status

Commands from a terminal are free; inside an agent they cost one model turn. Key commands: status (what it learned and session costs), microskills (injected and forming facts), toolprune (removed tools and evidence), toolprune restore (give tools back), config (view or change settings). Defaults: tool pruning and loop guard on, micro-skills off. Per-session switches include TE_DISABLE=1 claude and TE_LOOPGUARD=off codex.

Safety boundaries, hardening & integrations

Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.

Declared capability surface (blast radius)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

Local filesystem read/write

Modifies local files; work on a clean Git branch or dedicated worktree.

Outbound network access

Makes outbound requests; verify telemetry settings and model data routing on private repos.

What are this agent's strengths and limitations?

Pros
  • Black-box by design: works through context the agent already reads and the agent's own settings, so the agent never needs to learn a new tool
  • Paper-backed evidence: on 277 SWE-Bench tasks mean cost fell 18.4–30.9% across five combinations, cheaper in all 30 repository × combination cells, Pass@1 up in 4 of 5
  • Every action is reversible and protected: facts need three confirming sessions and are dropped when contradicted, removed tools are restorable, the loop guard only redirects
  • Local-only learning in ~/.tokeneconomizer; its model calls ride your existing login, need no new API key, and are included in its cost reports
Limitations
  • Feature coverage differs per host: tool pruning works only on Claude Code, Codex and Copilot CLI, and is unavailable on Pi, Grok Build, Factory Droid and several others
  • Experimental hosts (Cursor, Grok, Antigravity, Hermes, Droid) rely on undocumented hook contracts, cover narrow version ranges, and have documented limits
  • Savings depend on reusing the same repository: one-off tasks or fresh repos benefit little, and micro-skills is off by default because its proposer adds model calls
  • The loop guard never stops a stuck turn itself; in headless runs an unattended flagged turn runs until it ends

How does this agent compare with similar options?

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
TokenEconomizer This agent 64 · Some gaps Agent plugin / skillFree + model costs ★ 8k 3d ago Python Codex · Claude Code
RTK Command Output Optimizer 72 · Some gaps CLIFree ★ 88k today Rust Codex · Claude Code
Cheap Agent 57 · Major gaps CLIFree + model costs ★ 342 today TypeScript Codex · Claude Code
Chisle 77 · Good CLIFree + model costs ★ 1.3k today JavaScript Codex · Claude Code

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Some gaps
64/ 100 5-point scale 3.2 / 5
Trust 19/29
Reliability 9/14
Adaptability 12/18
Convention 11/18
Effectiveness 9/13
Verifiability 4/8
Why each dimension lost points
Trust19 / 29 · 3.3/5

README states the plugin holds no API key and never handles credentials, routing model calls through the user's own agent login; tool pruning only appends its own entries, never touches user deny rules, keeps created settings files out of git via .git/info/exclude, and is reversible via toolprune restore with restored tools not removed again; the loop guard only redirects and tells the user to stop, never stopping a turn itself. These are documentation-level claims not executed in this static review, so trust criteria score 2 rather than 3.

Reliability9 / 14 · 3.2/5

pyproject.toml declares dependencies=[] with a stdlib-only package, pytest only for tests, and optional extras that are empty or explicitly labeled; README gives supported version ranges per agent and notes older-version behavior, and states that on failure the session carries on as if the plugin were not installed. Concrete failure-message formats and error-handling code are not shown in the evidence, so 2.

Adaptability12 / 18 · 3.3/5

README covers Claude Code, Codex, Copilot CLI, Pi and experimental opencode, documenting per-agent tool-pruning capability differences, command syntax differences, where notices appear and how to stop turns in headless runs, plus TE_DISABLE-style env vars for per-session toggles; trigger thresholds (k/p/m/s/c/r/b) all have defaults and explanations. opencode support is labeled experimental and untested in the 2.x TUI, which is disclosed boundary rather than a defect.

Convention11 / 18 · 3.1/5

README is well structured with install, update, supported versions, command table, settings table, repository layout, citation and license; LICENSE is full Apache-2.0; SECURITY.md gives a vulnerability reporting path; package.json and pyproject.toml both at 0.1.0. Deduction: no CHANGELOG or version history, and version is only 0.1.0, so versioning_changelog scores 1.

Effectiveness9 / 13 · 3.5/5

README reports 18.4–30.9% lower cost on SWE-Bench, cheaper in 30/30 cells, Pass@1 up in 4/5 combinations, with cost including the plugin's own model calls and cache pricing; status/microskills/toolprune/config commands let users inspect learned facts and costs. These are author-reported measurements not reproduced here, so 2.

Verifiability4 / 8 · 2.5/5

README maps each mechanism to concrete thresholds, defaults and written file paths, and links docs/PLUGIN.md, docs/ARCHITECTURE.md, experiments/README.md and the arXiv paper, making claims traceable; cross-source corroboration is limited to in-repo docs and a paper link with no independent third-party verification, so cross_source_corroboration scores 1. For fact_inference_separation, README distinguishes measured results from design principles and flags opencode as experimental and partly untested, giving basic separation of fact and inference.

Risks and how to mitigate them
  • This is a static source review with no installation or execution; the cost and Pass@1 figures in README are author-reported and not independently reproduced.
  • The plugin edits local agent settings files (e.g. .claude/settings.local.json, .codex/config.toml, .github/copilot/settings.local.json); confirm these are not tracked by the repository or already carrying custom rules before installing.
  • opencode support is labeled experimental, tested only on 1.19.5 and 2.2.0 and not in the 2.x terminal UI; use with caution in production.
  • Micro-skills is off by default; enabling it adds model calls and cost, so weigh it against the repository and workload.
  • The repository is at version 0.1.0 with no CHANGELOG, so upgrade paths and breaking-change records are incomplete.
Evidence confidence: Low Reviewed Nov 01, 2026 Reviewed revision 883284806639
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/tokeneconomizer.svg)](https://followagents.com/en/agents/tokeneconomizer)
<a href="https://followagents.com/en/agents/tokeneconomizer"><img src="https://followagents.com/badge/tokeneconomizer.svg" alt="FARS review"></a>

FAQ

How are the plugin's own model calls billed?
The fact proposer and the loop guard's judge run through your own logged-in agent, on the same plan or login, and their cost is included in the plugin's cost reports. No separate API key is needed, and by default a model is called only when the loop guard acts.
Does my data leave my machine?
Learned facts, tool evidence and settings live in ~/.tokeneconomizer on your machine; the plugin never handles credentials and has no cloud service of its own.
Could it break my tasks?
It is built to protect task success: facts form only from repeated evidence, tools are removed only after going unused and can be restored, the loop guard leaves progressing turns alone, and if any part of the plugin fails your session carries on as if it were not installed.
Which agents and versions are supported?
Full support for Claude Code 2.1.300–2.1.329, Codex 0.153.1–0.171.0, Copilot CLI 1.0.83–1.0.114 and Pi 1.2.0–1.5.2; opencode, Cursor Agent, Grok Build, Hermes Agent, Antigravity CLI and Factory Droid are experimental.
Can I try it before committing to its behavior?
Yes: toolprune=propose only proposes the deny list; microskills=envfacts learns only from repeated failures with no model calls; and TE_DISABLE=1 turns the whole plugin off for a session.
Is TokenEconomizer free?
The software is free, but TokenEconomizer calls an AI model, and you pay that model provider for usage (or run a local model).
Is TokenEconomizer open source?
Yes. The source code is on GitHub (microsoft/TokenEconomizer) under the MIT licence.
Is TokenEconomizer safe to use?
FollowAgents' FARS review (Nov 01, 2026) scored TokenEconomizer 19/29 on trust and safety. None of the eight safety controls the review checks for was missing outright.
Is TokenEconomizer still maintained?
Yes. The latest commit on GitHub is from 2026-11-20, within the last 30 days.
Who makes TokenEconomizer?
TokenEconomizer is published by Microsoft. FollowAgents verified that the GitHub account microsoft belongs to Microsoft.
Was this page helpful?
View on GitHub ↗ Install ↓

Host ecosystems

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts