To Run or Not to Run: Analyzing the Cost-Effectiveness of Code Execution in LLM-Based Program Repair
LLM-based coding agents increasingly adopt a “generate-run-revise” paradigm, where iterative test execution is used to refine patches. This execution-centric approach has become standard practice in state-of-the-art systems. However, executions can be time-consuming and costly, and their prevalence and impact in these agents remain underexplored. In this paper, we conduct a two-stage empirical study to analyze execution behavior in LLM-based program repair. First, we analyze 7,745 agent traces from SWE-bench leaderboard submissions to characterize execution behavior at scale. Second, we perform controlled experiments on 200 SWE-bench instances across two agents (Claude Code and Codex) under four execution paradigms, enabling fine-grained comparison of performance and cost. Our analysis reveals several key observations: ❶ Code execution is used across all agents and models analyzed, with an average of 8.8 test runs per task. Execution behavior varies substantially across agents and models, with frequency ranging from 2 to 19 per task. Late-stage executions (66–100% of conversation) consistently achieve higher success rates than early-stage ones, with an average success rate of 57.9%. ❷ The resolve rate difference between Prohibited (environment-restricted) and Unrestricted (fully-configured) modes is only 1.25 percentage points, which is not statistically significant (𝑝 > 0.05). Prohibited mode consumes 56–62% fewer tokens and 48–54% less time for Claude Code. ❸ Execution has limited impact because 57–62% of repairs are completed in a single edit without requiring feedback, localization accuracy remains above 95% without execution, and 81–100% of failed cases passed agent-executed validation but failed official evaluation. Overall, execution is common but often adds little, so agents should run tests only when needed (especially near the end) to save cost with little change in repair quality. These observations provide empirical insights into the role of execution in agent-based repair and may inform future research on execution-efficient agent design.