SAO: Single-Rollout Asynchronous Optimization for Long-Horizon Agent Reinforcement Learning

    This article introduces SAO, a single-rollout asynchronous optimization approach for long-horizon agent reinforcement learning. It explains why group-based synchronous sampling struggles with long-tailed rollouts, policy lag, and context growth, then describes SAO’s sampling design, asynchronous pipeline, context compression, system coordination, evaluation metrics, and deployment guidance.

    SAO: Single-Rollout Asynchronous Optimization for Long-Horizon Agent Reinforcement Learning

    1. Background: Why Long-Horizon Agent RL Needs a New Paradigm

    Typical long-horizon agent reinforcement learning tasks are no longer single-turn question answering. They involve combinations of multi-turn tool calls, code editing, test feedback, error repair, and environment interaction. A complete trajectory may contain dozens or even hundreds of decisions. The training system must handle growing context while maintaining high throughput between sampling and training. Traditional synchronous RL pipelines face three prominent conflicts in this setting.

    First, sampling long tails are significant. Group-based sampling usually requires generating multiple trajectories for the same input task and then estimating advantages based on relative results within the group. If one trajectory in a group takes too long, the entire group blocks training, causing GPU idle time and queue jitter. Second, off-policy effects accumulate. Long trajectories take longer to generate. If training waits for an entire group to finish, the policy version associated with the samples may already lag behind the current training policy. The higher the degree of asynchrony, the more obvious the policy lag becomes. Third, context costs rise quickly. Tool outputs, test logs, and historical observations rapidly fill the context window. Without compression mechanisms, effective credit assignment over long trajectories becomes difficult.

    SAO (Single-rollout Asynchronous Optimization) proposes a lighter-weight path to address these conflicts: replace group-based sampling with single-rollout sampling, let each input task generate only one rollout that can immediately enter the training queue, and use an asynchronous pipeline plus context compression to push long-horizon agent RL toward higher throughput and more stable training.

    2. SAO Core Mechanism: From Group Sampling to Single-Rollout Sampling

    The advantage of group-based sampling is that multiple trajectories from the same input provide relative comparison signals, reducing the impact of reward noise on advantage estimation. The cost is synchronous waiting, within-group long tails, and lower sample utilization. The core change in SAO is that each input task samples only one trajectory and sends it to the training side as soon as possible. The direct benefit is that sampling and training are decoupled, and samples are no longer blocked by the synchronization barrier of “waiting for the whole group to finish.”

    It is important to note that single-rollout sampling does not mean abandoning advantage estimation. In engineering practice, variance is usually controlled through value baselines, historical reward normalization, importance weighting, or clipping mechanisms. Compared with group-based sampling, the single-rollout approach reduces reliance on within-group relative comparisons, making the optimization signal closer to the current policy. At the same time, because the delay before samples enter the training queue is shorter, policy version gaps are easier to control, and off-policy effects are relatively reduced. For long-horizon agent tasks, this “sample immediately, train immediately” approach better matches the real distribution of long trajectory durations and obvious long tails.

    From a generalization perspective, single-rollout sampling avoids strong correlation comparisons among multiple trajectories from the same input, so the training signal is closer to the real online interaction distribution. However, it also introduces new challenges: the reward variance of a single trajectory may be larger, and this must be compensated through stable baseline estimation, reward shaping, and asynchronous version management. Therefore, SAO is not simply “sampling fewer trajectories.” It is a holistic redesign of sampling strategy, asynchronous scheduling, and training stability mechanisms.

    3. Asynchronous Optimization Pipeline: Throughput and Policy Lag Control

    The engineering value of SAO is mainly reflected in the asynchronous pipeline design. The sampler continuously generates single-rollout samples, while the trainer pulls batches from the queue for training. The two coordinate through version numbers, priorities, and capacity levels. An illustrative pseudocode example is shown below:

    1. # Illustrative pseudocode: single-rollout asynchronous training loop
    2. for task in task_stream:
    3. policy_version = current_policy_version()
    4. trajectory = rollout_once(task, policy_version)
    5. trajectory = compress_context(trajectory)
    6. reward = evaluate(trajectory)
    7. queue.push(trajectory, reward, policy_version)
    8. while training:
    9. batch = queue.pop_batch(max_version_gap=K)
    10. advantages = compute_advantage(batch, baseline)
    11. loss = policy_loss(batch, advantages, importance_weight(batch))
    12. update_policy(loss)

    The key to asynchrony is controlling “freshness.” If samples in the queue have excessively old versions, policy lag amplifies off-policy bias. If freshness is pursued too aggressively, queue depth may be insufficient and training resources may sit idle. In practice, it is necessary to monitor policy version gaps, importance weight distributions, clipping rates, and queue wait times, and to set maximum version gaps, dynamic batch sizes, and timeout retry strategies. For long-tail trajectories, priorities and timeout fallbacks can be set to prevent a single abnormal trajectory from occupying sampling resources for a long time.

    In addition, the asynchronous pipeline needs to handle length differences within batches. Token length distributions for long-horizon trajectories are highly uneven, and simple batching causes padding waste. Effective throughput can be improved through length bucketing, dynamic batching, sequence packing, and gradient accumulation. On the system side, routing and scheduling should be jointly aware of load with the training system, balancing allocation by sampling difficulty, task type, and resource levels to reduce local hotspots.

    4. Context Compression: Making Long-Horizon Trajectories Manageable and Trainable

    In long-horizon Coding RL and multi-turn agent tasks, context expansion is a major enemy of training stability. SAO supports context compression. Its goal is not simple truncation, but reducing token cost while preserving key state. Common practices include hierarchical summaries of historical tool outputs, preserving error information, key file paths, test conclusions, and unfinished steps; deduplicating and aggregating repeated logs; and compressing early observations in a traceable way so that key events required for credit assignment are not lost.

    Context compression must be co-designed with reward evaluation. If compression is too aggressive, the model may not see the key evidence that led to failure. If compression is insufficient, long contexts slow down both sampling and training. In engineering practice, a combination of “key-event tagging + segmented summaries + recent-window retention” can be used, and compression ratio, task success rate, and long-horizon step returns should be observed in training monitoring. For code-related tasks, it is especially important to preserve test failure information, patch diffs, and call-chain summaries rather than retaining all raw logs.

    5. System Coordination and Throughput Evaluation

    SAO’s throughput gains come from coordination across sampling, training, and scheduling. The sampling side uses single rollouts to reduce synchronous waiting. The training side uses an asynchronous queue to smooth peaks. The scheduling side reduces long-tail blocking through joint load balancing between routing and the training system. In public technical materials, this type of combination has reported an end-to-end training throughput improvement of more than 2.3x for long-horizon coding reinforcement learning. In engineering deployment, measurements should be based on the actual cluster, task distribution, and model scale, and fixed numbers should not be applied directly.

    Evaluating whether SAO is effective should not rely on throughput alone. It should also observe effective training samples per unit time, policy version lag distribution, importance weight clipping rate, reward variance, long-horizon task success rate, context compression ratio, and rollback frequency. If throughput improves but clipping rate or variance deteriorates significantly, the degree of asynchrony has exceeded the stability boundary, and queue depth should be reduced or sample freshness increased.

    6. Suitable Scenarios and Deployment Recommendations

    SAO is better suited to long-horizon, tool-call-intensive agent RL scenarios with obvious sampling long tails, such as multi-turn code repair, test-driven development, and complex environment interaction. For short tasks or tasks with extremely noisy rewards, group-based sampling can be retained as a baseline, or a hybrid sampling strategy can be used: group-based sampling for short tasks to stabilize variance, and single-rollout asynchrony for long tasks to improve throughput.

    For deployment, a staged approach is recommended: first validate the variance and convergence of single-rollout sampling on small-scale tasks, then introduce the asynchronous queue and version-gap control, and finally add context compression and joint scheduling. All performance data should be based on reproducible experiments, and throughput conclusions from a specific cluster should not be directly extrapolated. Overall, the value of SAO lies in using finer-grained sampling and tighter asynchronous coordination to move long-horizon agent RL from “waiting for the whole group” to “sampling and training concurrently,” providing an engineering-friendly optimization path for long-trajectory training.