ChengRang

TokenEconomizer

AI Coding Open Source

Open cost controller for coding agents from Microsoft Research and UC Berkeley that learns repository facts, prunes unused tools and interrupts failure loops, cutting per-task cost by up to 30 percent

cost controlcoding agentsopen sourcetool pruninglocal state
Visit TokenEconomizer

Disclaimer: Review content represents our editorial team's views and experience, not commercial recommendation or investment advice. Product info and pricing may change; refer to official sources.

Overview

TokenEconomizer is an open cost controller from Microsoft Research, UC Berkeley and Microsoft Security. It treats coding agents as a black box, learns from the sessions an agent has already run in a repository, and uses that experience to cut waste in the sessions that follow. It changes no model weights and no agent code, working only through prompts, tool settings and the event stream.

The waste comes from three places, all measured in the paper. On a repository used repeatedly, once five tasks precede the current one about 30 percent of tool calls repeat an earlier action. Every request ships more than twenty tool definitions, and most are never called. Failure loops account for 10 of 60 analysed runs but 32 percent of total spend. Each waste pattern maps to a mechanism.

Micro-skills record repository facts one line at a time, such as running python -m pytest when pytest is missing, injected only after three sessions confirm them and retired when later sessions contradict them. Tool pruning drops tools that go unused across sessions and restores them with one command. The loop guard redirects once when a turn looks stuck, then tells you how to stop. State lives in ~/.tokeneconomizer on your machine, and the controller's own model calls are included in its cost reports.

Key Features

Use Cases

Pros

Pricing

Open source under Apache 2.0 as a standard-library Python package with plugins per agent, requiring Python 3.10 or newer and needing neither a GPU nor its own API key. Supported agents are Claude Code, Codex, the GitHub Copilot CLI and Pi, with opencode support still experimental. Learned state lives in ~/.tokeneconomizer. Tool pruning and the loop guard are on by default while micro-skills is off, and an envfacts mode learns only from repeated failures without model calls. Status is available through /tokeneconomizer:status.

Summary

Half of a coding agent's bill is spent on repetition: the same repository, the same conventions, relearned by every new session. TokenEconomizer's judgement is that this belongs to the repository rather than the model, so experience is stored locally, injected on demand, and unused tool definitions are removed from each request. The 30 percent it saves is not squeezed out of a context window but comes from not repeating the same mistakes.

Version History

Category
AI Coding
Pricing
Open Source
Tags
cost control · coding agents · open source
Website

Related Tools