# TokenEconomizer: Experience-Driven Black-Box Cost Control for Coding Agents
<!--
ref: @content/web/arxiv/2026-10-15-tokeneconomizer-experience-driven-black-box-cost-control
tags: [coding-agents, token-cost, black-box-control, tool-pruning, agent-evaluation, swe-bench]
version: 2
updated_at: 2026-11-21T17:14:07.612Z
-->

**[Read the original](https://arxiv.org/abs/2610.22732)**


*Synthesized from Aaron J. Li, Weijia Xu, Chandan Singh, Zixiao Chen, Jeevana Priya Inala, Charlotte Siska, Acar Tamersoy, Bin Yu, Ion Stoica, Michel Galley and Jianfeng Gao's paper on arXiv, 2026-10-15.*

TokenEconomizer is an external, black-box controller that lowers cumulative token cost for coding agents working through a sequence of tasks in the same repository. It changes only the prompt, the loaded tools and the event stream, not model weights or agent-loop code. Across Claude Code, Codex and GitHub Copilot CLI with frontier models, the authors report 18.4 to 30.9 percent lower average token cost with comparable task success on SWE-Bench.

## Core Thesis

The authors argue that per-task efficiency evaluations miss how developers actually use coding agents, which is continuously building and maintaining a project. Over such task sequences, costs recur in environment-specific ways that fixed strategies do not handle well. Their answer is adaptive, black-box cost control learned from completed traces.

## Key Insights

- **Fixed strategies are inconsistent.** RTK (command-output compression), Serena (semantic navigation) and Aider's RepoMap each cut cost in some repositories and raised it in others; all three reduced cost on Django but increased it on SymPy.
- **Three sources of removable cost.** Operational actions repeat within a repository and make up 12 to 28 percent of tool-call bytes; of 23 loaded tool schemas, no repository uses more than 7 and 16 are never called; failed tasks are 17 percent of tasks but 32 percent of spend.
- **Experience-grounded micro-skills.** One-line operational facts (for example, how to run tests) are proposed from trace digests every 5 tasks, checked by regex or predicate detectors, and activated only after confirmation on 3 non-overlapping-edit tasks with a need rate of at least 0.4. Retirement uses a decayed support score (gamma=0.8, lambda=5), and retired skills are never reactivated.
- **Tool pruning.** Core shell and file tools are always kept. Other tools are removed after 3 consecutive unused tasks or an LLM judge's irrelevance verdict, and a full-catalog re-audit runs every 5 tasks to recover mistaken removals.
- **Failure-loop intervention.** The turn budget is 1.25 times the 90th percentile of turns in passing tasks. A rule-based trigger calls an LLM judge (confidence 0.7); the agent is redirected once and stopped if the loop recurs, with a forced stop at 2.5 times budget under a strict stall rule.
- **Main SWE-Bench results (TokenEconomizer alone).** Cost change and Pass@1 by setting: Claude Code with Sonnet 5, minus 23.6 percent, 76.0 (default 74.7); Claude Code with Opus 4.8, minus 30.9 percent, 73.0 (default 74.0); Codex with GPT-5.6 Terra, minus 24.7 percent, 74.7 (default 73.8); Codex with GPT-5.6 Sol, minus 26.1 percent, 81.7 (default 80.1); Copilot CLI with Sonnet 5, minus 18.4 percent, 77.6 (default 75.0).
- **Ablations (Claude Code).** Tool pruning gives minus 13.2 percent (Sonnet) and minus 17.7 percent (Opus); micro-skills give minus 11.8 and minus 14.3 percent; the failure-loop guard gives minus 7.1 and minus 5.4 percent. No single component reduces Pass@1 by more than 3 points.
- **Adding existing tools.** Adding RTK gives up to minus 33.2 percent (Opus 4.8) and adding RepoMap up to minus 29.2 percent (Sol). Cost fell in all 30 repository-setting cells, from 5.2 to 40.1 percent.
- **Generalization.** On Web-Bench, cost fell 21.2, 16.0 and 18.7 percent across Claude Code, Codex and Copilot, with Pass@2 rising for Claude Code and Codex. On CredData and ReposVul (security detection), cost fell 6.4 to 19.6 percent with F1 changes that were mostly neutral or positive.
- **Stated limits.** Each meta-strategy can err (a stale skill, a wrongly pruned tool, or a productive task mistaken for a loop). Only three harnesses were tested, not minimal ones such as Pi, and SWE-Bench streams are independent fixes rather than real user sessions.

## Actionable Takeaways

- Profile tool-call bytes and loaded tool schemas per repository before tuning: in the paper, repeated operational actions were 12 to 28 percent of tool-call bytes and 16 of 23 tool schemas were never called.
- Prune tools that have gone unused for 3 consecutive tasks, while always keeping core shell and file tools, and re-audit the full catalog periodically to recover mistaken removals.
- Cap turns per task at 1.25 times the 90th percentile of turns in passing tasks, and redirect the agent once before forcing a stop.
- Gate any learned operational note behind a check: a detector plus confirmation on several non-overlapping tasks before it is activated.
- Evaluate cost over task sequences in one repository, not only isolated tasks, because early tasks can cost more while cumulative savings reach 16.9 to 32.0 percent.

## Notable Quotes

The abstract's framing, paraphrased from the arXiv page: adaptive black-box cost control is presented as a promising direction for reducing coding-agent token costs. No other direct quotes from the authors were used.

---

*Related: `@content/web/aiweekly/2026-11-01-harvard-coding-agents-flat-shipped-output` · `@content/youtube/ai-jason/2026-07-20-tmux-fable-cut-35-less-token` · `@content/youtube/ai-jason/agent-folder-is-making-claude-code-10x-better` · `@content/youtube/every-inc/2026-02-18-openai-s-codex-this-model-is-so-fast-it-changes-ho` · `@content/youtube/lennys-podcast/2026-04-02-an-ai-state-of-the-union-weve-passed-the-inflection-point-da`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*