Manuscript Offprint

arXiv:2611.22901

Done, But Still Working: Anytime Evaluation of When Coding Agents Should Stop

Zerui Yang, Quan Xue, Miaomiao Dong, Chaorui Zhang, Xuanyu Zheng, Xiyuan Wang, Haolin Ruan, Xueyan Niu, Guangcheng Song, Weixi Zhang, Wei Han, Bo Bai

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Coding agents often continue working after their own tests pass. Does this additional work improve the patch, and how much could be saved by stopping earlier? We study these questions through anytime evaluation: replaying recorded runs, scoring intermediate patches with hidden tests, and measuring the cost incurred at each step. For policies that only stop a run or select an earlier patch, this allows paired comparisons without generating new trajectories, provided replay preserves the relevant states. Across about 6,000 runs of eight open models in two scaffolds on SWE-bench Verified, we find substantial differences in the value of continued work. The hindsight saving available at passing self-tests ranges from under 1% to 57%, depending on the model and scaffold. A rule that stops after the same patch passes twice saves 23% in a preregistered replication, but the preregistered quality test does not establish non-inferiority. We explain these differences by measuring how often a rule fires, how often the patch changes afterwards, and whether those changes repair or break it. Fine-tuning agents to imitate the rule saves 30% over six seeds, while quality preservation remains uncertain. Our results help identify both the opportunities and the risks of early stopping.

1 Introduction

Figure 1: Stopping saves cost, but its effect on patch quality depends on the agent. Two rules are compared with running to the end on the same recorded runs: stop at the first passing self-test, or after two passes on the same patch. Left: inference cost saved at c=0.1c=0.1. Right: change in local resolution under corrected scoring D′D^{\prime} (percentage points). Point estimates use all runs of the five model–scaffold combinations shown in Figure 4, including derivation runs; these descriptive results are not the held-out confirmation test. “mini denotes mini-SWE-agent.

Coding agents search repositories, edit code and run tests to solve software issues (Jimenez et al., 2024; Yang et al., 2024; Wang et al., 2025). Testing helps an agent check its work, and the mini-SWE-agent prompt explicitly asks it to test edge cases before finishing (SWE-agent team, 2025). Yet a passing test does not necessarily end the run. The agent may run more tests, revise the patch or perform cleanup. These actions incur additional cost, and they may either fix remaining problems or introduce new ones. Figure 1 shows how two simple stopping rules trade cost against resolution across models and scaffolds.

This raises three questions. How much do agents spend after their tests pass? When does continued work improve the final patch? Can an agent stop earlier without losing those improvements? A benchmark score for the final patch cannot answer these questions because it does not show whether an earlier patch was already correct.

We address this gap with anytime evaluation (Section 2). We replay recorded commands in an executable sandbox and evaluate intermediate patches with hidden tests. We also calculate the cost incurred up to each command. The resulting trajectory shows when a patch becomes correct, whether it later breaks, and how much the remaining work costs. Hidden-test results from evaluation tasks are never shown to the agent. A separate training-only label ablation is identified explicitly.

This approach also lets us compare stopping rules on the same runs. If a rule only ends a run or selects an earlier patch, it does not change the actions that precede its decision. Provided those states are faithfully recorded or replayed, we can evaluate what the rule would have submitted without running the model again. Interventions that change the agent’s behavior, such as fine-tuning, still require new runs.

We first measure the cost of continued work and the precision of paired comparisons. We then examine how much stopping could save, evaluate practical rules, and explain their quality differences. Finally, we test whether agents can learn to imitate a stopping rule.

References (24)