R113 · Agent architecture › Context economics and caching

TokenEconomizer: coding agents that learn to spend less

Read the original

coding-agentscostcontextmemoryopen-source

Source: Microsoft Research blog, TokenEconomizer: Learning from Experience to Make AI Coding Agents More Efficient (2026-11-16); paper arXiv 2610.22732; code microsoft/TokenEconomizer. UC Berkeley, Microsoft Research and Microsoft Security.

The problem, measured

Profiling a coding agent on 60 SWE-Bench tasks run in sequence per repository found three recurring kinds of waste:

Three popular fixed-strategy cost plugins each helped in some repos and hurt in others, which argues for per-repository adaptation.

Architecture

A black-box controller that runs beside an unchanged agent and model. After each session it reads the log, updates a per-repo model, and acts through three mechanisms using only interfaces the agent already exposes:

  1. Micro-skills. One-line repo-specific notes proposed from recurring patterns, added to the starting context only after several sessions confirm them, and retired when later evidence contradicts them.

  2. Tool pruning. Drops tools history says are unlikely to be used, always keeping shell and edit tools; pruned tools can be restored.

  3. Failure-loop intervention. A judge model decides whether a repeating failure is genuinely stuck; if so the agent gets a short redirect note, and if still stuck the developer is alerted rather than the run being killed.

It needs no API key of its own, keeps what it learns on the developer's machine, and reported savings net out its own model calls.

Results

Tradeoffs and failure modes

Review checklist

Other entries on context economics and caching (index subtopic 1.5) and on agents learning from their own history (1.2).

Connections

See R113 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.