TL;DR
Training AI agents with reinforcement learning often burns massive compute on attempts that are either way too hard or way too easy, yielding weak learning signals. This paper shows mathematically that binary-reward learning peaks at a 50% success rate, and introduces Prefix Sampling—a clever feedback controller that replays partial trajectories as "head starts" or "handicaps" to steer tasks right into that 50% Goldilocks zone. The result? Up to a $2\times$ wall-clock training speedup on complex software engineering benchmarks without requiring external hints or extra rollout budgets.
What Problem Does This Paper Address?
When training language models on math or coding using Reinforcement Learning with Verifiable Rewards (RLVR), algorithms like Group Relative Policy Optimization (GRPO) have the model attempt a problem multiple times—say, 8 "rollouts"—and compare the binary outcomes (pass or fail) to see which actions were better.
If an agent gets 0/8 or 8/8 passes, there is zero contrast; you learn nothing about what separates success from failure, so standard pipelines throw those "degenerate" groups away. However, the authors noticed that in long, expensive software-engineering tasks, even the surviving groups are heavily skewed—like 1/8 or 7/8. Because rollout generation dominates compute and wall-clock time, spending hours generating skewed groups with weak contrast is painfully inefficient. Prior work tried fixing this using external teacher hints or dynamically changing batch budgets, leaving open the question: can we maximize the learning signal of skewed groups on the fly using only the model's own attempts?
Methods
First, the authors formalize Rollout Pass-Rate Control (Rollout-PRC), proving that a 50% pass rate (4/8 passes) simultaneously maximizes four distinct measures of learning signal: reward entropy, probability of surviving 0/8 and 8/8 filtering, leave-one-out advantage energy, and the number of success–failure pairs.
To actively steer training toward 50%, they introduce Prefix Sampling (PS) over a standard GRPO++ backbone:
- Bidirectional Prefix Selection: Degenerate groups (0/8, 8/8) are discarded, and balanced groups (3/8 to 5/8) train normally. Skewed groups, however, also seed future "rerollouts." Mostly failing groups (1/8, 2/8) save a successful attempt's beginning as a head start. Mostly passing groups (6/8, 7/8) save a failing beginning as a handicap.
- Replay-Through-Execution & Masking: For stateful coding agents, you can't just paste text prefixes—the code environment has to match. PS feeds saved prefix actions back through the environment parser/executor to reconstruct the exact sandbox state, skipping expensive LLM generation for those steps. When the current policy takes over to finish the trajectory, Prefix Masking zeroes out the loss on replayed tokens so the model only gets credit (or blame) for its fresh continuations.
- Adaptive Prefix Control: As the model improves, a fixed prefix length goes stale. A closed-loop feedback controller tracks an exponential moving average of rerollout pass rates for each bucket (1/8, 2/8, 6/8, 7/8), dynamically lengthening or shortening the prefix ratio to keep continuations locked near 50%.
Datasets
- Software Engineering (Agentic RL): Trained on R2E-Gym-Subset and evaluated on SWE-bench Verified.
- Mathematical Reasoning (Single-turn RL): Trained on AceReason-Math-Subset—a newly curated dataset of ~15,000 harder problems built by running Qwen3-4B-Instruct-2507 (8 rollouts per problem) on AceReason-Math and filtering out problems with a $\ge 75\%$ pass rate. Evaluated on AIME 2025.
Key Insights and Ideas
- Easy tasks are wasted opportunities unless handicapped: Most hint-based methods only rescue hard problems. By intentionally feeding failing prefixes to 6/8 and 7/8 groups, PS forces the model to practice self-correction—recovering from a bad start—extracting rich contrastive signal from problems the model has otherwise "mastered."
- Quantity of valid groups isn't enough; quality matters: In ablations, replaying a fixed 50% trajectory length actually preserved more non-degenerate groups per batch than adaptive control (85.1 vs. 80.2), yet converged slower. Steering rollouts accurately into the 50% pass-rate sweet spot matters more than sheer group survival.
- Double-dipping on agentic speedups: In stateful coding tasks, executing saved text commands in a terminal is much faster than waiting for an LLM to generate them. Prefix replay cuts per-step wall-clock time while also reducing the total steps needed to converge.
Key Results
Across four Qwen3 backbones (4B, 8B, 14B, 32B), Prefix Sampling consistently reached baseline peak performance levels in fewer steps and less time:
- SWE-bench Verified: Qwen3-14B reached the baseline's step-300 peak at step 170 ($1.76\times$ fewer steps) and improved peak Pass@1 from 0.274 to 0.295 (+4.7 percentage points at the same checkpoint), achieving a $2.01\times$ end-to-end wall-clock speedup (66.3h vs. 133.1h). Qwen3-32B achieved a $1.55\times$ end-to-end speedup (172.9h vs. 268.0h) and a +5.4 pp same-step gain at its peak (0.422).
- AIME 2025: Qwen3-4B and Qwen3-8B reached baseline peak levels with $1.68\times$ and $1.23\times$ evaluation wall-clock speedups, posting +7.3 pp and +10.8 pp same-step Pass@1 gains at their respective peaks.
- Dead-on Control: On the 4B math run, PS cut degenerate 0/8 and 8/8 rerollouts nearly in half (51.3% $\rightarrow$ 26.8%) and pulled mean rerollout pass rates for the 1/8, 2/8, 6/8, and 7/8 buckets to 0.485, 0.489, 0.504, and 0.515.
Limitations and Future Work
- Local vs. Global Scope: Prefix Sampling only intervenes on partially successful skewed groups (1/8 to 7/8); it still discards 0/8 and 8/8 groups and treats 50% as a local continuation target rather than a global curriculum optimizer.
- Matched-Protocol Scope: The authors evaluate PS strictly as a drop-in, fixed-budget controller rather than benchmarking against protocol-changing methods (like off-policy SFT mixtures or oracle-prefix systems).
- Descriptive Agentic Diagnostics: While 14B SWE logs confirm that rerollouts concentrate near the 50% band (29.62% vs. 14.54% for fresh groups), the authors note this offline audit is descriptive and does not independently isolate causal effects or controller convergence in the SWE setting. Future directions are not explicitly discussed in the main text.
Summary updated