TL;DR
While large language model (LLM) agents are increasingly adept at fixing software bugs, directly using bug reproduction tests (BRTs) to guide them often backfires by causing "partial fixes" or misleading the agent entirely. SWE-Doctor overcomes this by generating multi-faceted tests, running them through an interactive debugger to extract structured runtime diagnoses, and using this rich execution data to guide complete patch generation. This approach achieves state-of-the-art results on challenging benchmarks like SWE-bench Pro, outperforming existing agents by up to 8.9 percentage points.
What Problem Does This Paper Address?
LLM-based software engineering agents typically resolve issues by reading a bug report, exploring a repository, and writing a patch. To verify their work, advanced agents often generate a Bug Reproduction Test (BRT)—a test case designed to replicate the reported bug.
Intuitively, if an agent can generate a test that reproduces a bug, it should be able to use that test as a target: just modify the code until the test passes! However, the authors discovered a surprising counter-trend: directly feeding state-of-the-art BRTs into patch-generation workflows does not improve overall success rates.
The authors identified two core reasons for this failure:
- Partial Patches (The "Fail-to-Pass" Problem): A single generated test often only exercises one specific symptom or code path of a multi-faceted bug. If the agent only optimizes for passing that single test, it stops early, leaving other required behaviors broken.
- Misleading Targets (The "Fail-to-Fail" Problem): If a generated test is imperfect or fails incorrectly, treating it as a strict pass/fail target misleads the agent, driving it further away from the correct fix.
Methods
To fix these issues, the authors developed SWE-Doctor, an agent that shifts the paradigm from treating tests as black-box pass/fail targets to treating them as rich, interactive debugging probes.
The SWE-Doctor pipeline consists of three main stages:
- Multi-Faceted BRT Generation: Instead of generating just one test, SWE-Doctor uses an LLM to decompose the issue report into multiple distinct behavioral requirements. It then runs a generate-execute-refine loop to create targeted BRTs for each facet.
- Runtime-Grounded Bug Diagnosis: SWE-Doctor executes these tests inside a real command-line debugger (like
pdbfor Python). An LLM debugging agent interacts with the debugger—stepping through frames, setting breakpoints, and inspecting variables—to construct a structured Diagnosis Record. This record details the suspected fault location, failure symptoms, propagation paths, and potential patch impacts. A strict "runtime-grounding check" ensures the agent actually gathers execution evidence rather than hallucinating a diagnosis from the text alone. - Multi-Source-Guided Patch Generation: The agent combines the high-level issue requirements with the low-level runtime diagnosis records to generate the patch. Before submitting, it runs a prompt-level completeness check to verify that all identified facets of the bug have been addressed.
Datasets
The authors evaluated SWE-Doctor on two prominent software engineering benchmarks:
- SWE-bench Verified: A human-validated subset of 500 real-world GitHub issues (filtered to 436 bug-fixing cases for this study).
- SWE-bench Pro: A more recent, highly challenging benchmark consisting of complex, enterprise-level software engineering problems (107 Python bug-fixing cases evaluated).
- Go Subset (SWE-bench Pro): 50 randomly selected Go language issues used specifically to test cross-language generalization.
Key Insights and Ideas
- Tests are more than pass/fail signals: Human developers don't just look at whether a test passed or failed; they look at stack traces, print statements, and variable states. SWE-Doctor proves that LLM agents also perform significantly better when given access to this internal runtime state via a debugger.
- Division of Labor: Ablation studies revealed that the two core components of SWE-Doctor solve different problems. Multi-faceted test generation primarily helps resolve "fail-to-pass" issues by preventing partial patches. Conversely, runtime-grounded diagnosis helps resolve "fail-to-fail" issues by extracting useful localization clues even when the test itself is imperfect.
- Cross-Language Portability: Because the core architecture relies on structured diagnosis records rather than language-specific heuristics, the system generalizes easily. Swapping Python's
pdbfor Go'sDelvedebugger allowed the agent to immediately improve performance on Go repositories.
Key Results
SWE-Doctor was evaluated across five different LLM backends (including variants of GPT, Claude, DeepSeek, and MiMo) and consistently outperformed the baselines (mini-SWE-agent and live-SWE-agent) in all 10 model-benchmark combinations.
- SWE-bench Verified: Achieved an average resolution rate of 75.7% (a 2.0 to 3.9 percentage point improvement over baselines).
- SWE-bench Pro: Achieved an average resolution rate of 59.4%, marking a substantial jump of 8.0 to 8.9 percentage points over the strongest baselines.
- Unique Solutions: SWE-Doctor uniquely resolved 108 issues that neither baseline could solve—more than double the unique resolutions of the baseline agents combined.
- Language Generalization: On the Go dataset, SWE-Doctor achieved a 36.0% resolution rate, outperforming the baselines (32.0% and 30.0%).
Limitations and Future Work
- Increased Running Cost: Operating an interactive debugger and generating multiple tests requires more LLM tokens. SWE-Doctor costs more per issue on average ($0.43 on Verified, $0.64 on Pro) than simpler baseline agents ($0.22–$0.52).
- Debugger Dependency: While the framework is generalizable, it still requires a language-specific command-line debugger interface to be configured and integrated into the agent's environment. Future work could explore automating the integration of debuggers for a wider variety of programming languages.
Summary updated