microsoft/TokenEconomizer
A hook-based coding-agent plugin that cuts repeat work and tool overhead.
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
TokenEconomizer is an in-process integration from the user's perspective, but it does not modify the host agent's code or model. It uses host hooks and session traces to learn repository facts, measure tool use, and establish what a normal turn looks like. Learning is scoped to each agent–repository pair, while settings are shared across agents. Interventions use interfaces the host already understands: injected context for facts and redirects, and native configuration for tool pruning.
The mechanisms, trace reader, ledger, and plugin runtime live in a Python package with no third-party runtime dependencies. The bundled plugin/scripts/te launcher does not require a separate package install. Pi has a TypeScript extension under plugin/pi/ and declares @earendil-works/pi-coding-agent in package.json. Despite working with MCP tools on some hosts, TokenEconomizer is a host plugin, not a standalone MCP server.
Key Capabilities & Differentiators
Micro-skills combine recurring failures with periodic model proposals. A fact enters the session-start context only after three sessions confirm it and is dropped if later evidence contradicts it. Tool pruning uses inactivity thresholds, but its precision depends on the host: individual tools in Claude Code, capability packages in Codex, and whole MCP servers in Copilot CLI. Pi has no pruning. The loop guard builds a baseline from successful turns, then evaluates suspected loops. It can bypass the judge when a turn repeatedly churns through the same edits and failures beyond 2.5 times its typical length. It redirects rather than interrupting execution.
Across 277 SWE-Bench tasks from six repositories, five agent–model combinations recorded 18.4–30.9% lower mean cost, and Pass@1 improved in four of five. Costs include cached-token pricing and the plugin's own model calls. Tasks were run in order within each repository starting with no learned state, so the aggregate result includes a cold start but is not a prediction for an isolated session.
Trade-offs & Limitations
Compared with hand-written repository instructions and a fixed tool allowlist, TokenEconomizer reduces manual upkeep by learning from what actually happens in sessions. The cost is a warm-up period and less predictable tool availability: pruning a whole MCP server can hide a rarely used but important tool along with the unused ones. Micro-skills are off by default because their proposer adds model calls, and the value of those calls depends on how often work repeats.
Pruning changes only plugin-managed entries, preserves existing deny rules, and can be reversed with toolprune restore. When a target file cannot be edited safely—for example, a tracked .codex/config.toml or invalid JSON—the plugin leaves a proposal instead of writing it. Measure billed cost and task completion together during a pilot. Use the terminal CLI for routine inspection when possible, since invoking the equivalent command inside the agent costs a model turn.
Hardware & Deployment Guide
Put Python 3.10+ on PATH and sign into a supported host. The standard plugin needs neither its own API key nor a GPU stack. Claude Code, Codex, and Copilot CLI install through a marketplace backed by a local clone, which must stay in place; Pi uses pi install git:github.com/microsoft/TokenEconomizer. Review host permissions during setup. Codex hooks take effect in the next session after approval, and Claude Code and Copilot CLI require a tool catalog refresh on initial setup and after host updates.
The first release, v0.1.0, covers 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, with a separate load-by-path route for Pi 0.99.x. Only the endpoints of the listed ranges were tested; newer versions are untested. Treat experimental hosts as separate rollout targets: for example, Cursor's tested headless configuration did not provide session usage, and its interactive TUI remains untested.
plugin/scripts/te; the Pi integration declares @earendil-works/pi-coding-agent.Teams that repeatedly use a supported coding agent in the same repositories and can compare billed cost, tool availability, and task success during a pilot.
Work mostly happens in one-off repositories, every tool must remain available, or policy rules out the extra model calls needed for the features you want.
Quick Start & Installation
git clone https://github.com/microsoft/TokenEconomizer.git claude plugin marketplace add "$PWD/TokenEconomizer" claude plugin install tokeneconomizer@tokeneconomizer
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| TokenEconomizer ★ | 8.3k | +173 | Python | MIT | A hook-based coding-agent plugin that cuts repeat work and tool overhead. |
| rtk | 88.7k | +684 | Rust | Apache-2.0 | A local Rust CLI wrapper that trims command output before coding agents read it. |
| ECC | 316.1k | +4.2k | JavaScript | MIT | Plugins and CLI workflows for planning, reviewing, and verifying agent-written c |
| caveman | 124.8k | +1.4k | Go | Apache-2.0 | Coding-agent skill and local Go proxy for shorter replies and smaller tool outpu |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/microsoft/TokenEconomizer.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about TokenEconomizer
Does TokenEconomizer run as a separate MCP server?
status to see what the plugin learned or changed and config to inspect the effective settings.What hardware and runtime overhead should I budget for?
local_model=fm; this does not make every model call local.Can we use it commercially and keep the deployment local?
When is it better than repository instructions and a manually curated tool list?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy