microsoft/TokenEconomizer

Experience-Driven Black-Box Cost Control for Coding Agents

What it solves

Coding agents are designed to complete tasks, but they often waste money by repeatedly performing the same inefficient actions. Every time an agent runs, it pays to rediscover basic facts about a repository (like build steps or command syntax), loads tools that never get used, and occasionally gets stuck in repetitive failure loops. TokenEconomizer reduces these costs by learning from past sessions to eliminate redundant work.

How it works

TokenEconomizer acts as a plugin that sits alongside your existing coding agent without modifying its core code or model weights. It tracks session history and applies three cost-saving mechanisms:

  • Micro-skills: It identifies and remembers repository-specific facts (like required environment variables or file locations) and provides them at the start of new sessions once they have been confirmed by repeated experience.
  • Tool pruning: It monitors which tools are actually used in your repository. If a tool remains unused over a set number of prompts and sessions, it is automatically excluded from future requests to save on token costs.
  • Failure-loop intervention: If an agent gets stuck in a cycle of repeated errors, a judge model identifies the loop and provides a brief nudge or redirect to help the agent try a different approach.

Who it’s for

It is for developers who frequently use AI coding agents—such as Claude Code, GitHub Copilot CLI, or Codex—on the same repositories. It is ideal for users who want to lower their AI usage costs without changing their workflow or switching to a different agent.

Highlights

  • Cost-effective: Reduces mean costs by 18.4–30.9% across various agent-model combinations.
  • Non-intrusive: Operates as a plugin that requires no API keys of its own and leaves the agent's core functionality untouched.
  • Reversible: Every action taken by the plugin is reversible; facts can be dropped if contradicted, and pruned tools can be restored with a single command.
  • Privacy-focused: All learned information stays locally on your machine in a dedicated directory.
  • Broad compatibility: Supports major agents like Claude Code, GitHub Copilot CLI, and Codex, with experimental support for several others.

Related

  • Project
  • Project
  • Project
  • Dispatch
  • Project