Zenodo - technical report (not peer-reviewed)
Clear Every Third Task: A Measured U-Curve in the Context Economy of Coding Agents
Evgenii Arsentev · ARSENTEV.AI · ORCID 0000-0002-9120-7298 · 2026-09-11
Abstract
Practitioners running LLM coding agents face a question with no published answer: how often should an agent's context be cleared? We ran a fixed suite of twelve programming tasks under six session-length policies — a fresh session every task, every two, three, four, six, and one session for all twelve — with six replicates each, holding the model, the tasks, their order, and the verification suite constant. Cost is not monotone in session length. It falls from $2.68 per run when the context is cleared after every task to $2.14 at every third task, then rises again to $2.47 when the context is never cleared.
Exact permutation tests show that clearing every third task is significantly cheaper than clearing after every task (p = 0.0022, the smallest value this design can produce) and than never clearing (p = 0.0108), while the differences between clearing every three, four and six tasks are within noise (p = 0.10 and p = 0.21). The optimum is therefore a plateau, not a point, and both of the policies teams actually use sit outside it. Task quality was identical everywhere: 4086 tests, zero failures, in every condition.
The U-shape decomposes cleanly. Cache writes fall monotonically with longer sessions (253k → 88k tokens) because each fresh session re-primes the cache, while context carried per model call rises monotonically (38k → 71k tokens) because nothing is ever dropped. Their product, cache reads, is U-shaped with a minimum at three. Because cache writes are priced at 12.5× cache reads per token on the model we used, neither term can be ignored. We release the run-level token counters and the harness.
Keywords: LLM agents, inference economics, prompt caching, context management, reproducible measurement, agentic systems, cost analysis
Cite
@techreport{arsentev2026clear,
author = {Arsentev, Evgenii},
title = {Clear Every Third Task: A Measured U-Curve in the Context Economy of Coding Agents},
institution = {ARSENTEV.AI},
year = {2026},
doi = {10.5281/zenodo.22699668},
url = {https://doi.org/10.5281/zenodo.22699668}
}