Manuscript Offprint

arXiv:2611.01181

Do Coding Agents Catch Their Own Bugs? (They Don't.)

Shaswat Patel, Michel Liao, Peter Henderson, He He, Valerie Chen

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

ABSTRACT

In software development, engineers need to foresee and fix potential problems with their code that are not explicitly specified in requirements—such as pre-emptively considering vulnerabilities or other bugs from a code change. But current benchmarks often do not measure these future-looking consequences. We introduce Foresight-SWE, a benchmark for measuring whether coding agents can anticipate and address unstated problems during software engineering tasks. Foresight-SWE consists of 212 samples spanning 4 languages and 35 popular open-source repositories. Each sample contains two pull requests (PRs), the second of which resolves defects the first one introduced. To measure whether agents exhibit foresight, we define the foresight resolve rate (FRR) as the fraction of instances where an agent fully resolves the original task while also avoiding the defect identified by a later PR. We evaluate eleven large language models and find that FRR ranges from only 6.13% to 24.53%, indicating that models largely fail to address problems introduced by the first PR change. This raises important questions about how models are trained and aligned in coding contexts, as well as how code review tools should be improved for more fail-safe coding. Foresight-SWE shifts evaluations in this direction.

GitHub

Benchmark

Leaderboard

1 INTRODUCTION

Coding agents are typically evaluated on software engineering tasks where the complete requirements are explicitly provided (Jimenez et al., 2024; Deng et al., 2025; Xu et al., 2025; Badertdinov et al., 2026). Real software tasks, however, are often under-specified (Yang et al., 2026a; Zhou et al., 2025), and recent work shows that coding-agent performance degrades under such conditions (Larbi et al., 2025; Laban et al., 2025). As coding agents take on more software engineering work, they should be able to forecast defects that are not explicitly described in the task. Figure 1 illustrates such a case. A Pytest contributor changed virtual-environment detection to use Python’s standard marker file, passed review, and merged the change. Twenty-three days later, a regression surfaced because conda environments do not create this marker, causing Pytest to incorrectly collect test files from installed packages.

Such latent defects are common and can impose substantial costs on maintainers and users. Django’s issue tracker¹ shows 4,225 tickets opened between August 2021 and August 2026, of which 1,988 (47.05%) were classified as bugs. Of these, 947 were resolved as fixed, amounting to roughly one fixed bug every other day. These bugs involved a median of four participants and five comments, and took a median of 5.3 days from report to fix. For the 22% not fixed within a month, the median time to resolution rose to 121 days, during which the defect remained live in released code.

Prior work studies related forms of robustness in coding agents, but existing benchmarks either frame the task as proactive debugging in an existing codebase with defects, or restrict evaluation to a narrow class of defects. Active-SWE (Li et al., 2026a) and SWE-Sweep (Lieret et al., 2026) evaluate whether agents can autonomously identify and repair defects in a repository without issue reports.

¹See here for Django’s issue tracker (called Trac).

Figure

Figure 1: Motivating Foresight-SWE. Consider a real case where, on Day 0, a tested and reviewed PR1_1 was merged. By Day 23, users had reported substantial downstream breakage, prompting an urgent discussion that also involved a maintainer of the conda package manager. On Day 25, a follow-up PR2_2 repaired the problem and closed the issue. This timeline motivates Foresight-SWE, which measures whether coding agents can foresee consequential failures.

However, unlike our setting, these benchmarks explicitly instruct agents to search for bugs rather than evaluating whether they proactively anticipate unstated defects to ensure software reliability while implementing a specified task. SecureVibeBench (Chen et al., 2026b) evaluates whether agents reproduce vulnerabilities introduced by human developers. However, its evaluation is limited to security vulnerabilities in C/C++ and uses security-specific static and dynamic analyzes, capturing only one aspect of reliable software development. In contrast, we introduce a scalable pipeline that leverages tests from subsequent real-world fixes to evaluate whether coding agents anticipate unstated defects while completing ordinary software development tasks, spanning diverse defect types and programming languages.

We introduce Foresight-SWE to measure whether coding agents can anticipate and address unstated edge cases while implementing a scoped task. To construct this benchmark, we mine PRs from open-source repositories and look for candidate pairs where one PR makes a change and a later PR fixes an edge case it missed. To identify valid pairs, we combine explicit maintainer references with information based on code history to reliably trace changes back to the earlier PRs. We then reconstruct executable repository states for both PRs, and validate each pair through test execution. We start from 11,609 candidate PR pairs, of which 492 remain after our construction and validation pipeline. From these validated pairs we introduce Foresight-SWE, which consists of 212 instances spanning four programming languages and 35 popular open-source repositories.

We find all tested models struggle with foresight compared to resolving the original task. On average, agents resolve the original task in 60.7% of instances. However, when considering foresight resolve rate (FRR)—the fraction of instances where the agent both resolves the original task and anticipates the defect later repaired by the follow-up PR—models achieve an average FRR of only 14.8%. When models are told the defect specifications, models can achieve a much higher average resolve rate of 91.2%, indicating the challenge is in recognizing the unstated defect. We find that proactive prompting can improve foresight (e.g., FRR increases by 11.32 percentage points for Claude Opus 5) but often trades off with the resolve rate of the original task. Surprisingly, in contrast, popular code review skills are not able to increase FRR. These results suggest that current agents are often capable of fixing a defect once it is known, but are much less reliable at recognizing during implementation that their own change introduces a failure mode that will surface later.

Contributions. First, we develop a scalable pipeline that mines real-world repositories, inspects their code history to produce paired instances of an original software change and a later fix for a defect introduced by that change. Second, we introduce Foresight-SWE, a benchmark built from real PR pairs where an initial change introduces a defect that is repaired only by a later PR. Third, we show across eleven models that they are much worse at foresight than task completion and realistic prompt interventions are not necessarily a reliable way of counteracting lack of foresight.

References (41)