AI
SWE-Ladder trains AI agents to fix code bugs through staged learning
A new training approach breaks down software debugging into localization, reproduction, and patching stages to significantly improve AI agent performance on real-world repository-level bugs.
Researchers have developed SWE-Ladder, a novel training framework that teaches AI agents to debug software repositories by learning stage-specific tasks rather than treating bug-fixing as a monolithic problem.
The Challenge of Repository-Level Debugging#
Fixing bugs in real code repositories demands multiple specialized skills: identifying faulty code, confirming the failure can be reproduced, and then crafting a working patch. Existing training methods fall short—reinforcement learning only signals whether the final patch succeeds, while prior self-distillation approaches expose the complete reference patch at every step without distinguishing between different debugging phases. Neither strategy gives agents targeted guidance for each repair stage.
How SWE-Ladder Works#
The method reorganizes training data to create stage-specific evidence from verified bug fixes. For each training example, the system extracts:
- Localization evidence: which files and lines contain the problem
- Reproduction evidence: which test cases expose the failure
- Patching evidence: the actual diff needed to fix the code
A rule-based router observes an agent's tool calls and assigns each step to the appropriate stage. A frozen teacher model then receives only the matching evidence for that stage. The stages are distilled in repair order—localization first, reproduction second, patching last—while GRPO optimization refines the full trajectory.
Measured Improvements#
Testing on the SWE-bench Verified dataset with a Qwen3-4B model, SWE-Ladder achieved notable gains. Under the R2E-Gym scaffold, the method lifted pass@1 accuracy from 9.6% to 16.4%, outperforming standalone GRPO (10.4%) and on-policy self-distillation (12.4%). Under OpenHands scaffolding, performance improved from 13.0% to 17.6%. Reversing the stage order degraded results to 11.4%, confirming that the localize-then-reproduce-then-patch sequence matters.
Why Stage Order Matters#
The finding that stage ordering significantly affects outcomes underscores a broader principle: teaching agents to solve problems in a logical dependency chain—rather than optimizing all aspects simultaneously—yields better learning outcomes and transfer to unseen bugs.

