Cross-Benchmark Transfer from RL on Agentic Coding Tasks
Summary (Overview)
- Single RL run, broad transfer: One epoch of reinforcement learning (GSPO) on just 1,700 expert-built coding tasks improved pass@1 on all six external benchmarks evaluated, spanning three different agent harnesses, with gains of +4.7 to +20.0 percentage points.
- Out-of-distribution generalization: Improvements held on four benchmarks released after training data collection (p = 0.004), under two harnesses never used in training (Terminus 2, Claude Code), and on multi-hour tasks with no horizon counterpart in training.
- Efficiency gains: The trained model also solved tasks in fewer agent steps—median trajectories fell 24–35% on DeepSWE and Terminal-Bench 3.
- Identified failure modes: Paired trajectory analysis revealed the base model's failures cluster into four "last-mile" modes (lost requirements, narrow testing, silent regressions, weak ground truth), all of which the trained model avoids.
- What transfers is behavior, not knowledge: The evidence suggests RL taught general engineering completion habits, not domain knowledge the base model already possessed.
Introduction and Theoretical Foundation
Background and Motivation
Coding agents frequently fail in the "last mile" of a task: they build most of a feature but drop a subtle requirement, test only cases their own implementation handles, break existing behavior, or validate against unchecked assumptions. The authors pose two questions:
- What does RL teach? Domain knowledge or general task-completion behavior?
- Does improvement transfer? Across benchmarks, harnesses, and horizons?
Standard RLVR (reinforcement learning with verifiable rewards) evidence typically shows gains only on benchmarks whose format matches training data. This paper investigates whether a small, expert-built training set can induce transferable engineering behavior.
Theoretical Foundations
The work builds on several established threads:
- RLVR for coding agents, established in mathematics and short-form code (DeepSeek-R1, GRPO), extended to long-horizon agentic software engineering (SWE-RL, SWE-Gym, DeepSWE-Preview).
- Partial-credit rewards proportional to fraction of tests passed, with the novel addition of a hard regression gate.
- Transfer from post-training: Prior work shows RL generalizes better than SFT to unseen variants, and can transfer across task distributions (e.g., office-work training improving SWE-Bench Pro).
- GSPO (Group Sequence Policy Optimization) for Mixture-of-Experts models, addressing token-level ratio fluctuations in GRPO.
Methodology
Training Data (1,700 Tasks)
Two task families from Surge AI's expert-built collections:
- Repository tasks (1,000): Real repos at pinned commits with change requests. Hidden fail-to-pass tests grade the requested behavior; pass-to-pass tests guard existing behavior. Specifications enumerate concrete, individually gradable requirements.
- Terminal tasks (700): Containerized environments with deliverables graded by expert-written hidden verifiers.
Four task properties shape the training signal:
- (P1) Gradable requirements: Each requirement maps to checks → partial credit possible.
- (P2) Hidden graders: Agent sees spec but never the tests → must decide its own checks.
- (P3) Protected behavior: Pass-to-pass tests enforce "what must not change"; a single regression zeroes the reward.
- (P4) No oracle: No reference solution provided → evidence of correctness must be self-produced.
All training tasks were checked against all six benchmarks—no overlap or derivation.
Reward Function
Let () be pass-to-pass test outcomes and () be fail-to-pass/verifier outcomes. The reward is:
- Partial credit: 3 of 12 checks passed scores 0.25.
- Hard gate: 12/12 new checks but 1/100 pass-to-pass failure scores 0.
Why partial credit matters: Under binary rewards with rollouts per group, a group is silent (no gradient signal) with probability —43% at , 66% at . Partial credit keeps ranking signal even when no rollout fully succeeds, while the gate prevents exploiting a trade between new and existing behavior.
Policy Optimization
GSPO with rank-32 LoRA adapter () on attention and MLP projections. For prompt with rollouts and rewards :
maximizing:
Key details: No KL penalty, no entropy bonus, no supervised warm-up. Truncated importance sampling corrects rollout/trainer numerical mismatch. 108 rollout steps, 216 optimizer updates total. Training on 64 NVIDIA H200 GPUs using open-source stack (Miles, SGLang, Megatron-LM, FlashAttention).
Evaluation Protocol
Six benchmarks, one harness each (fixed for both models):
| Benchmark | Tasks | Harness | Departure from Training |
|---|---|---|---|
| SWE-Bench Pro | 731 | mini-swe-agent | Same format |
| DeepSWE v1.1* | 113 | mini-swe-agent | Larger features |
| Terminal-Bench 2.1 | 89 | Terminus 2 | Same format; unseen harness |
| Terminal-Bench 3* | 74 | mini-swe-agent | Harder tasks; open internet |
| Terminal-Bench 4* | 66 | mini-swe-agent | As TB 3 (revised) |
| SWE-Marathon v1.1* | 20 | Claude Code | Multi-hour; unseen harness |
*Released after training data collection. Terminal-Bench 4 revises Terminal-Bench 3 (8 removed, 19 fixed), so they form one family.
Empirical Validation / Results
Main Results (Table 2)
| Benchmark | Harness | Tasks | Base | +RL | Gain (pp) |
|---|---|---|---|---|---|
| SWE-Bench Pro | mini-swe-agent | 731 | 60.1 | 64.8 | +4.7 |
| DeepSWE | mini-swe-agent | 113 | 31.0† | 43.4 | +12.4 |
| Terminal-Bench 2.1 | Terminus 2 | 89 | 67.4† | 82.0 | +14.6 |
| Terminal-Bench 3 | mini-swe-agent | 74 | 1.4 | 12.1‡ | +10.7 |
| Terminal-Bench 4 | mini-swe-agent | 66 | 0.0 | 7.6 | +7.6 |
| SWE-Marathon | Claude Code | 20 | 5.0 | 25.0 | +20.0 |
†Publicly reported baseline. ‡8 of 74 runs failed for harness reasons (not scored); 8 of remaining 66 pass.
Statistical Significance
- Pooled across 5 independent task sets (TB 3/4 counted once via TB 4): Cochran–Mantel–Haenszel test rejects equal pass rates at p < 0.001.
- Post-release benchmarks only (3 independent sets): improvement significant at p = 0.004.
- Individual significance (Boschloo's exact test, no multiple-comparison correction): TB 2.1, 3, 4, and DeepSWE vs. in-house base.
Efficiency Gains
- DeepSWE: median agent steps fell from 150 → 98 (−35%).
- Terminal-Bench 3: median steps fell from 102 → 78 (−24%).
Near-Miss Analysis (DeepSWE Base Failures)
Of 83 failed in-house base runs:
- 84% preserved every pass-to-pass test.
- 59% passed ≥80% of target tests.
- Median failed run passed 86% of target tests.
Paired Trajectory Analysis: Four Failure Modes
| Stage | Failure Mode (Base) | Behavior After RL | Task Property |
|---|---|---|---|
| Understand | Lost requirements: built most of feature but dropped a subtle constraint | Implements entire specification; carries every requirement through | (P1) Gradable requirements |
| Test | Narrow testing: tested only cases the incomplete implementation handled | Tests the requirement, not the implementation; derives cases from spec | (P2) Hidden graders |
| Maintain | Silent regressions: broke existing behavior while satisfying new requirement | Protects existing behavior; tracks "what must change" vs. "what must not" | (P3) Protected behavior |
| Verify | Weak ground truth: validated against false assumption or weak proxy | Reconstructs ground truth (e.g., method of manufactured solutions, differential testing against self-written emulator) | (P4) No oracle |
Illustrative examples:
- FastAPI task: Base passed 121/137 tests but defined methods at module level instead of on middleware object; trained model made them instance methods, passed all 137.
- Spectral solver: Base assumed 1-D problem and validated against data from same assumption; trained model used method of manufactured solutions with an analytic 2-D solution.
- Zstandard decompressor: Trained model wrote a compressor first to generate test inputs for round-trip verification.
Theoretical and Practical Implications
What Transfers Is Behavior, Not Knowledge
The base model already possessed the domain knowledge required (it was a frontier 1T-parameter model). The training did not teach new facts about FastAPI, PDE solvers, or compression—it taught a completion discipline:
- Treat the specification as a contract to be met in full, not approximately.
- Test what was asked, not what was built.
- Track what must remain unchanged alongside what must change.
- Produce independent evidence of correctness when no oracle exists.
Implications for RL Training Design
- Small, expert-built datasets can suffice: 1,700 tasks with rich, enumerable requirements outperformed the implicit assumption that scale of synthetic data is necessary.
- Partial credit + regression gate is a powerful reward shape: It maintains gradient signal on hard tasks where all rollouts fail, while eliminating the incentive to trade new behavior for regressions.
- Task properties determine learned behaviors: The four training properties (P1–P4) map directly onto the four behavioral changes observed, suggesting deliberate task design can target specific failure modes.
Practical Significance
- Gains on post-release benchmarks (TB 3, TB 4, SWE-Marathon) demonstrate robustness against benchmark contamination concerns.
- Improvement under unseen harnesses (Terminus 2, Claude Code) suggests the learned behavior is harness-agnostic.
- Multi-hour horizon transfer (SWE-Marathon: 5% → 25%) indicates the training generalizes beyond its own temporal scope.
Conclusion
One epoch of GSPO RL on 1,700 expert-built coding tasks, with a rank-32 LoRA adapter and a partial-credit reward gated on regressions, improved Kimi K2.7 Code on all six external benchmarks evaluated (+4.7 to +20.0 pp). The gains held on benchmarks released after training data collection, under harnesses absent from training, and on tasks with horizons far beyond anything in the training set.
The paired trajectory analysis shows the base model's failures were predominantly near-misses—most of the feature built, one or two requirements dropped, existing behavior mostly preserved. The trained model avoids these failures by implementing the full specification, testing requirements rather than implementations, protecting existing behavior, and constructing independent ground truth.
The central conclusion: What transferred was not domain knowledge—which the base model already had—but a way of finishing work. The training tasks and reward function favored specific engineering habits, and those habits generalized across benchmarks, harnesses, and task horizons.
Future directions suggested by this work:
- Exploring whether even smaller, more targeted task sets can induce specific behavioral changes.
- Investigating which task properties (P1–P4) are necessary vs. sufficient for transfer.
- Extending the approach to other agentic domains beyond coding (e.g., data analysis, research tasks).
Related papers
- Delivered, Not Used: Evaluating Agent Memory at Its Point of Use
MemUse reveals that LLM memory systems deliver mostly irrelevant or unused content, with task outcomes hiding beneficial use in failures and harmful use in successes.
- MetaCurate: Evolving Curation Filters for High-Quality Agentic Coding Data
MetaCurate evolves executable curation filters via pairwise LLM feedback, achieving state-of-the-art SWE-bench scores without model training and at 3.5x lower search cost.
- SWE-Trail: History-Guided Trajectory Collection for Coding Agent Training
SWE-Trail uses prior attempt history to guide where to collect coding trajectories, improving student model resolution by 2.33 points on SWE-bench Multilingual without exposing history to the agent.