Counterfactual Rollout Replay: Forkable Environments as Free Process Rewards for Software Engineering Agents
Yuanhao li, Hongbo Wang, Xuhong Chen, Yiming Cao, Xunzhu Tang
NeurIPS page · Open on the map
Category: LLM Post-Training: RL & Distillation › Reward-Driven Agentic RL with LLMs · Type: new method · Keywords: software engineering agents, reinforcement learning, credit assignment, environment replay, containerised tasks, process rewards
Areas: LLM Reasoning › Reasoning Optimization › Credit Assignment in Reasoning; Code & Coding Agents › Code Verification › Software engineering agents; AI Agents › Agent Optimization and Evaluation › Agentic Reinforcement Learning; Evaluation & Benchmarks › Agent Capabilities and Memory › Agent and Policy Evaluation; RL for LLMs & Agents › Language Model Agents › World Models for Agents
Summary
Counterfactual Rollout Replay (CRR) introduces a training-time replay procedure that re-executes containerised software environments from decision points with alternative actions, providing dense advantage signals without a learned process reward model and improving software engineering agents on benchmark suites.
Explained to a 5-year-old
Software agents try to fix code problems. They only get a reward when they finish, which makes it hard to know what they did right. The paper lets the computer replay the work from different choices, comparing what happens if you do one thing versus another, to give better feedback. This helps the agents learn faster and fix more problems.
Explained to a 5-year-old, longer
A computer program is trained to help fix bugs in software. Usually it only gets a reward after it finishes the whole task, so it cannot tell which steps were good or bad. The paper shows a way to replay the same software environment from earlier points, trying different actions each time. By comparing the results of the original action with the results of the alternative actions, the program can see which choices were better. This gives it more helpful feedback during training. The replay uses container images and commit hashes so the exact software state can be restored quickly. Because the replay does not need a separate reward model or human labels, it is simpler and cheaper. The method helps the program learn faster and solve more real-world coding problems with fewer training attempts.
For a technical reader
The paper introduces Counterfactual Rollout Replay (CRR), a training procedure that re-executes containerised software environments from decision points with alternative actions. By comparing on-policy returns with counterfactual returns, CRR provides dense advantage signals without needing a learned process reward model. It works by forking the environment using a commit hash and container image, replaying trajectories, and using the return differences to update the agent. This approach reduces the credit-assignment bottleneck that plagues sparse-reward reinforcement learning in software engineering. The authors evaluate CRR on SWE-Gym, SWE-bench Verified, and SWE-rebench, showing higher resolution rates with fewer trajectories than baseline GRPO.
Problem
Training software engineering agents on long-horizon tasks suffers from a credit-assignment bottleneck because rewards are only available at the end of trajectories, making it difficult to evaluate intermediate decisions. This sparsity limits learning efficiency and performance.
Method
The approach re-executes the environment from selected decision points with alternative actions, computes advantage as the difference between on-policy and counterfactual returns, and uses these advantages to update the agent. It requires no learned process reward model or human annotations, only extra environment-replay compute.
Results
The approach achieves higher issue resolution rates while requiring substantially fewer training trajectories than outcome-only GRPO, and it complements other advances such as PRM-based scoring and trajectory search.
Contributions
A training-time replay procedure that generates free process rewards by forking containerised environments, eliminating the need for learned reward models or human annotations, and an empirical demonstration on software engineering benchmarks showing improved performance with fewer trajectories.
Practical relevance
It enables more efficient training of software engineering agents that can resolve real-world code issues with reduced compute and time.
Research questions this paper is counted under
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction