AI Research

Stop Paying Your Agent to Relearn Your Repo

TokenEconomizer learns repo habits to cut agent costs 18.4-30.9% while holding accuracy steady.

StartupHub.ai Staff

By StartupHub.ai Staff, reviewed by Daniel Singer, Editor

3 min read

TokenEconomizer plugin learning from coding agent sessions
Credit: Microsoft Reesarch

Why do coding agents charge you to learn the same repo twice? Microsoft Research says TokenEconomizer, an open-source plugin built with UC Berkeley and Microsoft Security, turns old sessions into savings on new ones.

It lowered mean cost per task by 18.4 to 30.9% across five agent-model pairs on 277 real bug fixes, the team reports.

A coding agent is software that reads code, runs shell commands and submits patches with little supervision. Each turn it resends tool definitions and chat history to the model, so tokens pile up fast. That bill repeats because teams run the same agent in the same repository every day. TokenEconomizer treats that repetition as training data instead of starting cold.

Profiling showed the waste is predictable.

Microsoft Research profiled Claude Code on 60 SWE-Bench tasks run in sequence. After five tasks in one repo, 30% of tool calls repeated an earlier action in that repo, versus 7% overlap across repos, the post says. It loaded 23 tool descriptions every turn while 16 went unused, and the 17% of tasks that failed ate 32% of spend, the post says. Fixed plugins helped in one repo and flopped in the next, so savings have to adapt per repo.

Microsoft Research says TokenEconomizer reads each session log and updates three controls through the agent's existing interfaces. Micro-skills are one-line notes about recurring repo facts that enter context only after several confirmations and retire if contradicted. Tool pruning drops tools history marks as unlikely to be used but always keeps command execution and file editing, with restore on demand. Failure-loop intervention uses a judge model to spot a stuck agent, nudges it to try another path, and in the open plugin pings the developer if it stays stuck.

On 277 SWE-Bench tasks across six repos, it saved money in all 30 repo and agent combinations with broadly stable success, the team reports. Pass@1 rose in four of five setups, cumulative costs fell below default by the sixth task in every repo, and savings are net of TokenEconomizer's own model calls, the team reports. The code is live at github.com/microsoft/TokenEconomizer, where per its GitHub page it promises cheaper runs in repos you use often without changing the agent. That promise held on Web-Bench with 16.0 to 21.2% lower cost and on security audits in new repos with 6.4 to 19.6% lower cost, the team reports.

Cutting reasoning effort saved as much but hurt accuracy, while TokenEconomizer did not. Watch build budgets in monorepos first, where the sixth-task payoff arrives fastest.

Sources

Get the free daily brief every morning

Every morning the day's AI news, new AI startups and new funding rounds. Free and takes a few minutes to read, unsubscribe at any time.

Join 64,000 other subscribers.

TopicsTokenEconomizerMicrosoft ResearchUC BerkeleyMicrosoft SecurityClaude CodeSWE-BenchWeb-Bench

StartupHub.ai StaffDaniel SingerWritten by StartupHub.ai Staff, Editorial teamReviewed by Daniel Singer, EditorAbout

StartupHub.ai Staff, Editorial team

The staff writers of StartupHub.ai, ranging from investment analysts to avid AI tool users, early adopters and critical enthusiasts. Backgrounds span engineering, business and the arts. We hold every piece to rigorous standards of research and review.

Daniel Singer, Editor

Daniel Singer is an AI expert who has been writing about, covering and building AI technology since 2018.

More from Daniel Singer

Test your Agent Readiness now

Paste your website. How well ChatGPT, Claude and the other agents can read and use a site, in about a minute.

Watch

The videos behind the news, one flip at a time

The feed mixes the videos from our articles with startup demos and you flip through them like TV channels for free with no signup.