TokenEconomizer
TokenEconomizer is a plugin that learns from prior coding-agent sessions in a repository to reduce costs by remembering repository facts, pruning unused tools, and intervening in failure loops without changing the agent.
Visit microsoft/TokenEconomizerOverview
TokenEconomizer is a plugin for coding agents that uses experience from earlier sessions in a repository to reduce repeated waste. It leaves the agent itself unchanged while learning repository facts, pruning unused tools, and intervening when a turn appears stuck. It supports Claude Code, Codex, the GitHub Copilot CLI, and Pi, with experimental support for several other agents.
Key Features
- Micro-skills learn repository-specific facts from repeated failures and periodic model review, inject confirmed facts at session start, and drop facts contradicted by later sessions.
- Tool pruning omits tools that remain unused across prompts and sessions, writes exclusions through each agent's own settings, and allows removed tools to be restored.
- Failure-loop intervention uses a judge model to detect stuck turns and can add a redirect by default at most once per turn, while leaving the decision to stop a turn to the user.
- The plugin works through the agent's existing context and settings, computes cost with cache pricing, and includes its own model-call costs in reports.
- It supports Claude Code, Codex, GitHub Copilot CLI, and Pi, plus experimental integrations for opencode, Cursor Agent, Grok Build, Hermes Agent, Antigravity CLI, and Factory Droid.
Use Cases
- Reducing repeated repository discovery and command spelling errors across many coding-agent sessions in the same repository.
- Cutting token and tool-definition overhead when an agent consistently loads tools it does not use.
- Detecting and redirecting turns that repeat the same failures while preserving user control over stopping a turn.
- Evaluating cost reductions on SWE-Bench, Web-Bench, and security-auditing tasks with supported agent-model combinations.
Getting Started
- Clone the TokenEconomizer repository and add its local marketplace for the chosen agent, then install the tokeneconomizer plugin.
- Start the agent in a repository, trust the folder when prompted, and run the agent-specific status command to confirm the plugin is working.
- Some hosts require a one-time tool catalog refresh after installation or after agent updates.
- Work as usual; the plugin announces each action in one line, and commands can show status, learned facts, pruned tools, and settings.
Deployment & Requirements
- Python 3.10 or newer must be on PATH.
- One supported coding agent must be signed in using any plan or login it supports; the plugin needs no API key of its own and does not handle credentials.
- Learned state is kept locally in ~/.tokeneconomizer.
- Cursor Agent and Antigravity CLI support is macOS and Linux only; Factory Droid was tested on macOS.
Before You Adopt
- License: Apache-2.0. Review its terms before using, modifying, or distributing the project.
- Micro-skills is disabled by default and must be enabled to use its model-based fact proposer.
- Agent command support was tested only on the oldest and newest versions in each documented range.
- Tool pruning is unavailable on some limited or experimental integrations.
- Learned data is stored on the user's machine.
- The plugin does not require its own API key and does not handle credentials.