Resolving a repository-level issue typically requires a software-engineering (SWE) agent to localize the faulty code, reproduce the failure, and patch the code. Reinforcement learning trains such agents from a single test result on the final patch, while on-policy self-distillation (OPSD) adds token-level supervision from a teacher with privileged evidence, exposing the full reference patch at every step. Neither provides stage-specific guidance for localization or reproduction. We propose SWE-Ladder, which turns the verified repair of each training instance into stage-specific evidence: the changed files and lines for localization, the fail-to-pass tests for reproduction, and the diff for patching. A rule-based router assigns each step of an end-to-end rollout to a stage based on its tool call, a frozen teacher sees only the matching evidence, and the stages are distilled in repair order while GRPO optimizes the full trajectory. With Qwen3-4B-Instruct-2507 on SWE-bench Verified under the R2E-Gym scaffold, SWE-Ladder improves pass@1 from 9.6% to 16.4%, compared with 10.4% for GRPO and 12.4% for OPSD with the full patch. Under the OpenHands scaffold, it improves pass@1 from 13.0% to 17.6%. Reversing the stage order under R2E-Gym reduces pass@1 to 11.4%.
Figures & tables
Figure 1: Supervision signals compared in this paper. GRPO assigns one reward to the whole trajectory; GRPO+OPSD shows the teacher the full reference patch at every step; SWE-Ladder gives the teacher stage-specific evidence and introduces the stages one at a time.
Figure 2: Stage-wise diagnostics on SWE-bench Verified. Bars show changes from the base model at the final checkpoint; labels mark the changes discussed in Section 1 . Base values appear under each metric. Definitions are in Appendix A.1 .
Figure 3: Stage-routed privileged distillation for SWE. A rule-based router labels each step of an end-to-end rollout as LOC, REP, or PATCH. In each phase, a frozen teacher receives one stage’s evidence and distills only that stage’s tokens, while GRPO optimizes the full trajectory.
Source corpus
Instances
Share (%)
SWE-smith ( Yang et al., 2026a )
500
43.5
SWE-ReBench ( Badertdinov et al., 2026 )
431
37.5
R2E-Gym ( Jain et al., 2025 )
155
13.5
SWE-Gym ( Pan et al., 2024 )
63
5.5
Total
1,149
100.0
Table 1: Training data composition. The collection contains 1,149 issues from four software-repair corpora.
Configuration
Training
pass@1 (%) ↑
Avg. steps ↓
env_done (%) ↑
R2E-Gym
Qwen3-4B-Instruct-2507 (Base)
—
9.6
26.5
84.2
GRPO
RL
10.4 ↑+ 0.8
82.9 ↑+ 56.5
36.0 ↓− 48.2
GRPO+OPSD
RL
12.4 ↑+ 2.8
39.7 ↑+ 13.3
67.4 ↓− 16.8
SDAR
RL
4.6 ↓− 5.0
34.5 ↑+ 8.0
88.0 ↑+ 3.8
SWE-Ladder
RL
16.4 ↑+ 6.8
19.3 ↓− 7.2
98.6 ↑+ 14.4
Table 2: SWE-bench Verified results. We report results for both the R2E-Gym and OpenHands ( Wang et al., 2025 ) scaffolds. Each configuration is evaluated in our environment with the scaffold listed in the table. All reported baselines and SWE-Ladder variants are evaluated in the same environment and protocol.
Figure 4: Four-view training dynamics on SWE-bench Verified. Localization, reproduction, verification, and pass@1, evaluated every 10 training iterations, for SWE-Ladder, SDAR, GRPO+OPSD, and the all-stages-at-once variant. Vertical guides mark the LOC, REP, and PATCH phases of SWE-Ladder .
Figure 5: Training-dynamics diagnostics. Entropy, gradient norm, response length, and shaped training reward of GRPO, GRPO+OPSD, SDAR, and SWE-Ladder over 70 iterations. Shaded regions mark the LOC, REP, and PATCH phases of SWE-Ladder .
Figure 6: Action counts per turn across checkpoints. For the base model, LOC30 , REP50 , and PATCH70 , each panel stacks the number of trajectories taking a search/read/view, file-edit, test/reproduction, or other action at each turn on SWE-bench Verified ( n=500 ).
Figure 7: Capability changes across checkpoints. Cells show changes (%) from Base for localization (Loc.), reproduction (Rep.), verification (Verify.), and pass@1 at Base , LOC30 , REP50 , and PATCH70 . Darker blue indicates a larger signed change.
Variant
Loc.
Rep.
Verify.
pass@1
Base
33.6
59.4
22.6
9.6
All at once
43.5 ↑+ 9.9
35.6 ↓− 23.8
12.6 ↓− 10.0
12.4 ↑+ 2.8
REP + PATCH
39.9 ↑+ 6.3
29.6 ↓− 29.8
11.8 ↓− 10.8
11.2 ↑+ 1.6
LOC + PATCH
42.4 ↑+ 8.8
37.6 ↓− 21.8
8.2 ↓− 14.4
13.2 ↑+ 3.6
LOC + REP
50.0 ↑+ 16.4
46.2 ↓− 13.2
11.6 ↓− 11.0
14.0 ↑+ 4.4
SWE-Ladder
52.0 ↑+ 18.4
60.0 ↑+ 0.6
30.0 ↑+ 7.4
16.4 ↑+ 6.8
Table 3: Stage ablation on SWE-bench Verified. Qwen3-4B-Instruct-2507 with R2E-Gym, n=500 . We report Loc., Rep., Verify., and pass@1; arrows indicate changes relative to Base. “All at once” applies the LOC, REP, and PATCH teacher contexts concurrently, with each routed response-token subset distilled from its corresponding context.
Training order
Solve (%)
Avg. steps
env_done (%)
LOC → REP → PATCH
16.4
19.3
98.6
PATCH → REP → LOC
11.4 ↓− 5.0
27.6 ↑+ 8.3
95.8 ↓− 2.8
REP → LOC → PATCH
12.6 ↓− 3.8
28.5 ↑+ 9.2
96.0 ↓− 2.6
Table 4: Effect of training-stage order. All schedules use 70 training iterations: 30 for LOC and 20 each for REP and PATCH. The blue row is the reference. Arrows show changes in percentage points for Solve and env_done, and in steps for Avg. steps.
Target
PI → target
Solve (%)
Avg. steps
env_done (%)
LOC
LOC → LOC
14.4
21.0
99.0
PATCH → LOC
13.6 ↓− 0.8
15.9 ↓− 5.1
98.8 ↓− 0.2
PATCH
PATCH → PATCH
13.2
34.0
82.8
LOC → PATCH
11.8 ↓− 1.4
20.2 ↓− 13.8
99.0 ↑+ 16.2
Table 5: Privilege–target stage alignment. All variants use a 30-step training budget. Rows are grouped by target stage; the aligned row in each group is the reference, and arrows show absolute changes for the mismatched PI condition.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 8: Neural router versus SWE-Ladder evaluation performance. Solve rates on SWE-bench Verified with the R2E-Gym scaffold. Both curves use the LOC → REP → PATCH training schedule and share a 9.6% Qwen3-4B-Instruct-2507 base point; they differ only in the router, neural versus rule-based. Lines connect the reported evaluation points.
Fail-to-pass test identifier and name; reference test code; candidate test change or reproduction starting point.
PATCH
Verified repair diff for the changed source file, including the intended replacement code.
Appendix
Table 6: Schematic examples of the stage-specific privileged information. The actual fields are populated from each instance’s verified repair metadata.
Step
Tool
Argument
Path
Assigned stage
1–3
search
nonce,add_id_token , …
/testbed
localization
4–7
file_editor
view
openid/connect/core/grant_types/
localization
8
file_editor
create
/testbed/reproduce_issue.py
reproduction
9
execute_bash
python3reproduce_issue.py
—
reproduction
10–11
file_editor
str_replace
openid/connect/core/grant_types/
patch generation
12
execute_bash
python3reproduce_issue.py
—
reproduction
Appendix
Table 7: A representative 21 -step trajectory (an oauthlib issue), labeled by the rule-based router of Appendix A.2 . Re-running the reproduction script while in PATCH demotes the state to REP (step 12), and the third consecutive inspection step returns it to LOC (step 15), so the label sequence is not monotone.
Evidence block
median
mean
p90
max
causal_localization
406
544
987
8,836
localized_issue_reproduction
1,249
2,928
7,084
32,604
patch_generation
669
907
1,864
9,893
union of all three (unrouted variant)
2,709
4,375
9,592
36,173
Appendix
Table 8: Tokens added by each privileged evidence block over the shared task prompt across the 1,149 training instances (Qwen3-4B-Instruct-2507 tokenizer).
Figure 9: Localization privileged information. Candidate files, old-side hunk ranges, and source fragments identify where the issue should be investigated without revealing the replacement patch.
Figure 10: Reproduction privileged information. Fail-to-pass tests, reference test snippets, and candidate test changes describe the failing behavior and provide a starting point for reproducing it.
Figure 11: Patch privileged information. The verified repair diff specifies the intended source-code correction available to the patch-stage teacher.
Repository-level software engineering (SWE) is a challenging long-horizon setting: agents must reason over extended interactions, use tools, and adapt to stateful environments. Recent work trains SWE agents with reinforcement learning methods such as Group Relative Policy Optimization (GRPO), which independently sample multiple trajectories per issue, test the resulting patches, and compare terminal rewards within a fixed group. However, this training setup does not reuse verifier feedback from failed patches as context for subsequent attempts, even though this feedback contains valuable diagnostic information about what went wrong. Training on recovery trajectories is challenging because the preceding outcome determines whether the next trajectory is generated, while the failed execution determines its conditioning context. We introduce FC-SWE, a failure-conditioned RL framework that incorporates recovery attempts into policy training. After a patch fails verification, FC-SWE restores the repository to its original task state and uses the failed patch and verifier feedback as context for a recovery trajectory. FC-SWE adapts GRPO to these chains of complete, multi-turn tool-use trajectories through two mechanisms. Trajectory-local rewards preserve each attempt's verifier outcome, preventing recovery success from rewarding an earlier failed patch. Active-set advantage estimation forms a comparison group from all initial and recovery trajectories actually executed for the same issue, so failed attempts remain in the group while unexecuted attempts are excluded. On all 500 SWE-bench Verified tasks under a verifier-assisted protocol, FC-SWE with Qwen3.5-4B and SWE-agent achieves 41.7% Resolved@1 and 52.8% Resolved@2, compared with 38.9% and 48.5% for GRPO. Although trained with at most two attempts per chain, FC-SWE reaches 70.7% Resolved@11 under an eleven-attempt test-time budget.
The pass-all-test binary reward has become a standard recipe for training software engineering agents, but its sparsity eliminates difference of partially correct patches. The test pass-rate is a natural alternative. However, we find that it is not a reliable indicator of patch quality. A functionality being tested can be covered by either one challenging test or one hundred trivial tests, where the majority might be already satisfied pass-to-pass tests. We introduce CodeLift, a reinforcement learning method that dynamically calibrates pass-rate rewards, turning the test suite into an adaptive curriculum. At each iteration, CodeLift groups tests that kill the same patches and patches that pass the same tests, then gives more weight to test groups that fewer patch groups pass. This reduces the impact of majority simple tests and focuses more on what is still challenging. Within each rollout, CodeLift applies the same scoring rule to repository snapshots, assigning credit to useful actions even when later ones introduce regressions. Experiments on SWE benchmarks show that CodeLift consistently improves pass@1/2/4/8 over binary and pass-rate baselines. Analyses show that CodeLift provides dense, stable learning signals and unlocks the inherent curriculum in the test suite.
Junjielong Xu, Huachao Zhu, Alyssa Wu +2
School of Data Science, The Chinese University of Hong Kong, Shenzhen · Tencent
LLM-driven software engineering agents have become a central testbed for real-world language-model capability, yet their training remains limited by the availability of high-quality SWE tasks. Existing synthetic data methods typically create tasks through fixed mutation or bug-injection procedures, making the resulting distributions largely independent of the agent's own weaknesses and training progress. We introduce Socratic-SWE, a closed-loop self-evolution framework that reuses the agent's historical solving traces as a source of training signal. Rather than treating traces only as evidence for reward computation, Socratic-SWE distills them into structured agent skills that summarize recurring failures and effective repair patterns. These skills then guide the generation of targeted repair tasks in real repositories. Candidate tasks are checked through execution-based validation and scored with a solver-gradient alignment reward, so that the retained tasks are both verifiable and useful for improving the Solver. The updated Solver produces new traces, enabling the task curriculum to adapt over successive rounds. Across SWE-bench Verified, SWE-bench Lite, SWE-bench Pro, and Terminal-Bench 2.0, Socratic-SWE consistently improves over self-evolving baselines under the same compute budget, reaching 50.40% on SWE-bench Verified after three iterations. These results suggest that solving traces can serve as a scalable substrate for self-evolving SWE agents.
Chuan Xiao, Zhengbo Jiao, Shaobo Wang +5
2Shanghai Jiao Tong University · 1AI Data, Alibaba Group