# Coding agent costs can fall when the repository remembers past work

> Source: <https://dev.to/deanlee/coding-agent-costs-can-fall-when-the-repository-remembers-past-work-lf0>
> Published: 2026-11-22 15:35:50+00:00

**Recommendation:** Track cost per accepted fix including review time, and keep repository notes only when savings persist past the roughly six-task break-even point.
More in the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

Before switching to a cheaper coding model, look at how much the current agent spends repeating work in the same repository. A Microsoft Research experiment suggests that retaining useful context can reduce model costs, although the result still needs to be checked against the quality and review cost of the fixes.

In a [report on TokenEconomizer](https://www.microsoft.com/en-us/research/blog/tokeneconomizer-learning-from-experience-to-make-ai-coding-agents-more-efficient/), researchers from UC Berkeley, Microsoft Research and Microsoft Security tested a plugin that learns from previous coding sessions. Across 277 SWE-Bench bug-fixing tasks in six repositories, they report average cost reductions of 18.4% to 30.9% across five agent and model combinations. The reported costs include the plugin's own model calls. Task success rates were broadly stable on their measures.

Those percentages are benchmark results, not a forecast for a particular team's bill. A useful comparison tracks the spend for agent and controller calls alongside accepted fixes and the time a person spends reviewing them.

The authors first profiled Claude Code on 60 SWE-Bench tasks run sequentially by repository. Once a repository had at least five completed tasks, 30% of tool calls repeated an action from an earlier task in that repository. The agent also received descriptions for 23 tools on every turn, even though 16 were never called. The 17% of tasks that failed accounted for 32% of spending. These observations describe that setup, not every production agent.

TokenEconomizer proposes short repository-specific notes after patterns recur, removes tool descriptions its history suggests are unlikely to be needed, and uses a judge model to detect repeated failure. Removed tools can be restored. If a stuck agent does not recover after a suggested change, the open-source plugin alerts the developer.

Each repository began without prior session history. In the authors' Claude Code cumulative-cost chart, early tasks could cost more while the plugin learned. Cumulative costs fell below the default by the sixth task in every tested repository. Six tasks is the observed break-even point in this experiment, not a guaranteed threshold for another codebase.

The researchers also report that reducing model reasoning effort produced similar or larger savings, but substantially degraded performance in their tests. For a team paying per task, a cheaper run can be a poor trade if it increases failures or repair work. Compare cost per accepted fix, and include review time when deciding whether a saved repository note is worth keeping.

The authors report savings on web-development and security-auditing benchmarks too, including audits where each task used a new repository. Those tests broaden the evidence, but they do not establish how much a specific team's changing codebase and review process will cost.
