TurnCost: Turns, Not Observations: Cache-Aware Loop Engineering for Coding Agents
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
AI coding agents operate in iterative loops: they modify code, run tools, inspect the results, and decide what to do next. We call the design of this process loop engineering, which includes context management, model selection, compaction, and termination. Existing efficiency work mainly compresses tool observations or routes selected turns to cheaper models, but the practical opportunity for these optimizations remains unclear. We analyze 600 publicly released coding-agent trajectories spanning two agent scaffolds and two language models. Median observations contain only 118-286 tokens, while the large build logs commonly used to motivate compression occur near the ninety-ninth percentile. Moreover, 98.6% of input tokens are served from a prefix cache, so flat input pricing overestimates loop cost by roughly 7x on average under near-ideal caching. We derive and empirically validate a closed-form break-even condition for model delegation. Delegation increases cost in half of the evaluated settings, near the predicted boundary. More broadly, turn count explains 84% of the variance in log trajectory cost, compared with 4% for mean observation size; the most expensive trajectories have the most turns despite having the smallest observations. These associations suggest that observation-focused methods target a secondary cost factor, and identify unnecessary turns as the larger and largely unexamined opportunity, though we do not establish that turns can be removed while holding task success fixed. We release TurnCost, a tool for re-scoring trajectory corpora under alternative caching, pricing, compression, and routing policies.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 14 of its 30 references that are in the map. First posted on arXiv 10 Oct 2026.
Builds on
14 of 30 references.
Closest ancestors · 5
Same direction, newest first
- 2026AgentRouter: Heterogeneous Model Routing for Cost-Optimal Multi-Step Agentic Workflows19 Sep
- 2026SWE-Router: Routing in Multi-turn Agentic Software Engineering Tasks30 Jun
- 2026Open-SWE-Traces: Advancing Dual-Mode Multilingual Distillation for Software Engineering Agents14 Jun
- 2025Reducing Cost of LLM Agents with Trajectory Reduction28 Sep
- 2025Difficulty-Aware Agentic Orchestration for Query-Specific Multi-Agent Workflows14 Sep
Other references · 9
- 2023SGLang: Efficient Execution of Structured Language Model Programscited by 1,141
- 2023FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performancecited by 853
- 2024Hybrid LLM: Cost-Efficient and Quality-Aware Query Routingcited by 372
- 2025Optimizing Model Selection for Compound AI Systemscited by 36
- 2025Adaptive LLM Routing under Budget Constraintscited by 24
- 2025Doing More with Less: A Survey on Routing Strategies for Resource Optimisation in Large Language Model-Based Systemscited by 20
- 2026Budget-Aware Agentic Routing via Boundary-Guided Trainingcited by 10
- 2026MTRouter: Cost-Aware Multi-Turn LLM Routing with History-Model Joint Embeddingscited by 10
- 2026Uno-Orchestra: Parsimonious Agent Routing via Selective Delegationcited by 6
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025More with Less: An Empirical Study of Turn-Control Strategies for Efficient Coding Agents
- 2026Agentic Coding in the Wild: Characterizing GitHub Copilot Traces at Production Scale
- 2026LoopsBench: From Harness Engineering to Loop Engineering in Coding Agent Evaluation
- 2026EvoCode-Bench: Evaluating Coding Agents in Multi-Turn Iterative Interactions
- 2026Understanding the Architecture of Coding Agents: An Exploratory Study Using a Research Prototype
- 2026Inside the Scaffold: A Source-Code Taxonomy of Coding Agent Architectures
- 2026SlopCodeBench: Benchmarking How Coding Agents Degrade Over Long-Horizon Iterative Tasks
- 2026An Empirical Cost Attribution of Context-Compression Gateways in Multi-Turn Coding Agents