Single-Trajectory Asynchronous Optimization: A Practical Guide to Long-Horizon Agentic RL
This article breaks down single-trajectory asynchronous optimization for long-horizon agent reinforcement learning, where each task can span hundreds of tool calls and exceed 100K tokens of context. It explains why group-based sampling, synchronous pipelines, and fixed-context assumptions break down at this scale, then details the core mechanisms: single-rollout sampling with a value model, doubly clipped importance sampling (DIS) to control off-policy drift, four engineering practices for value model stability, and context compression. It also covers system-side concerns such as joint scheduling of routers and training clusters, backpressure control, evaluation criteria, and a practical adoption checklist.
1. The Starting Problem: Why Long-Horizon Agentic RL Stalls
Recent agent reinforcement learning practice has exposed a structural contradiction: the stronger the model, the longer the interaction trajectory required per task; and the longer the trajectory, the more concentrated the problems of sampling cost, storage cost, and training stability become. A typical coding task may require dozens of rounds of tool calls, file reads and writes, and test executions, with a single trajectory easily exceeding 100K tokens of context. At this point, three implicit assumptions of the traditional RL pipeline begin to fail.
The first assumption is that “the same prompt can be cheaply resampled.” Group-based sampling (represented by GRPO) generates multiple rollouts for each input task and uses within-group relative advantage in place of an independent value estimate. This is highly cost-effective for short-output tasks such as mathematical reasoning, but in long-horizon agent tasks, sampling a single trajectory is already expensive. Group sampling means costs scale linearly, and multiple trajectories within a group are often highly homogeneous, so marginal information gain decays rapidly.
The second assumption is that “sampling and training can be approximately synchronous.” A synchronous pipeline requires all rollouts to finish before training begins as a batch, so long-tail trajectories leave the rest of the compute idle. Once this is relaxed to asynchronous, samples that arrive early are held back waiting for a policy update; by the time they are actually used for training, the policy that generated them is already several steps behind. Off-policy deviation is amplified, importance ratios spiral out of control, and training collapse becomes the norm.
The third assumption is that “context length is fixed and negligible.” In long-horizon tasks, observation information (tool returns, logs, error stacks) occupies a large number of tokens, but these tokens are not the model’s own decisions. Including them in advantage estimation introduces noise.
Single-trajectory asynchronous optimization is a systematic solution aimed at these three points: replace group sampling with a single rollout, replace the synchronous barrier with an asynchronous pipeline, and use a complete set of bias-control mechanisms to keep asynchronous training within a “near-policy” range.
2. Breaking Down the Core Mechanisms
2.1 Single-Rollout Sampling: Replacing “Within-Group Comparison” with “Absolute Value”
The key to single-trajectory sampling is not simply setting the group size to 1, but solving the problem of how to estimate advantage after losing the within-group baseline. The answer is to introduce a value model that provides a state-value baseline, with advantage computed as the difference between the actual return and that baseline. This brings three chained benefits:
- Sampling cost drops from O(group_size) to O(1), substantially increasing the total number of samples affordable for long-horizon tasks;
- Every trajectory is “fresh” and can be fed into training immediately, without waiting for other trajectories in the same group, greatly reducing idle time in the asynchronous pipeline;
- Advantage degradation caused by within-group homogeneity is avoided, leading to more stable generalization.
The cost is the introduction of the value model as an extra component, along with its own training stability issues—which is exactly what Section 2.2 addresses.
2.2 Doubly Clipped Importance Sampling (DIS): Constraining Asynchronous Drift
In asynchronous training, there is a lag between the behavior policy (the policy that generated the samples) and the target policy (the policy currently being updated). Standard importance sampling corrects on only one side and has extremely high variance; doubly clipped importance sampling truncates and normalizes both the numerator and the denominator, constraining the importance ratio within a controllable interval and thereby suppressing gradient explosions. In engineering terms, it can be understood as adding a constrained weight term to the loss:
# Illustrative pseudocode: doubly clipped importance weightsratio = torch.exp(logp_target - logp_behavior) # current policy / behavior policyw = torch.clamp(ratio, min=1.0 / clip, max=clip) # two-sided clippingw = w / w.mean().detach() # normalize to keep expectation at 1loss = -(w * advantage * logp_target).mean()
There are three practical points: the clipping threshold should not be too small, or the gradient signal is erased; normalization significantly mitigates weight-scale drift across different batches; and the behavior policy’s probabilities must be persisted alongside the samples, otherwise the weights cannot be recomputed after the fact.
2.3 Four Engineering Details for Value Model Reinforcement
The value model is the load-bearing wall of the single-trajectory approach, and its training stability directly determines whether the whole system can run for the long haul. Practices repeatedly validated in industry include:
- Increase the value model update frequency: update the value model twice for every single update of the policy model, so the baseline keeps up with changes in the policy distribution faster and the variance of advantage estimation is reduced.
- Freeze the attention modules and optimize only the expert projection layers: under a mixture-of-experts architecture, training only the MoE projection parameters greatly reduces the range of parameter perturbation in the value model, suppresses training fluctuations, and significantly lowers optimizer state overhead.
- Skip token-level generalized advantage estimation (GAE) over observation tokens: propagate advantage signals only between the action tokens generated by the model; observations such as tool returns and logs do not participate in advantage backpropagation, avoiding misjudging environmental noise as policy quality.
- Scale up value model pretraining data: the value head is prone to inaccuracy during cold start, so pretraining on larger-scale data whose distribution is closer to downstream tasks is the most effective way to shorten the “baseline calibration period.”
2.4 Context Compression: Making Long-Horizon Trajectories Trainable
The context of a long-horizon trajectory grows monotonically and eventually exceeds the trainable window. The goal of context compression is to compress history while preserving the information necessary for decisions: summarize early tool outputs, deduplicate repeated failed attempts, and structurally retain key intermediate artifacts (such as the list of modified files and the list of passed tests). It naturally fits single-trajectory sampling—because there is only one trajectory, the compression strategy does not have to worry about breaking within-group comparability.
3. The System Side: Training Frameworks and Joint Scheduling
Algorithms are only half the story. The throughput bottleneck of long-horizon asynchronous RL usually appears at the scheduling layer: an imbalanced resource ratio between the inference side (the engine generating rollouts) and the training side (the cluster updating parameters), routers mixing long and short requests and causing long tails, and failed retries amplifying load.
A continuously evolving training framework needs to optimize in three directions at once:
- Co-design of algorithms and systems: jointly consider clipping, compression, and parallel partitioning strategies with memory and bandwidth constraints, rather than patching things up after the fact;
- Joint scheduling of the router and the training system: route by estimated trajectory length into buckets, separate long and short requests into different pools, and use load balancing to prevent individual nodes from being dragged down by long trajectories;
- Backpressure control in the asynchronous pipeline: limit the number of in-flight samples and the maximum policy lag in steps, trading controllable “staleness” for throughput rather than accumulating samples indefinitely.
In comparable practice, this combination can more than double end-to-end training throughput for long-horizon coding RL (publicly reported figures are around 2.3x) and support stable training for thousands of steps without collapse.
4. Results and Evaluation Criteria
Evaluating long-horizon RL requires distinguishing two types of capability: reasoning accuracy on short outputs and task completion rate on long trajectories. The former is commonly measured with hard mathematical benchmarks, where single-trajectory asynchronous optimization shows a clear advantage over group-sampling baselines under the same base model (publicly reported figures: 97% vs. 84% on a certain math benchmark); the latter is commonly measured with real repository-level bug-fixing benchmarks, with reported values around 30%. It is worth emphasizing that these numbers depend heavily on the base model, data, and inference budget. When comparing across approaches, the pass@1 criterion and sampling budget should be unified, otherwise the conclusions are not transferable.
If readers want to reproduce similar capabilities in their own environments, they can use a container platform to host the training and inference clusters, object storage to persist trajectories and checkpoints, a message queue to decouple sampling from training, and logging, monitoring, and alerting services to track lag steps and gradient norms—these general-purpose cloud components are enough to build an observable asynchronous RL pipeline.
5. Adoption Checklist
- Quantify the trajectory length distribution first, then decide whether asynchrony is needed; group sampling is more cost-effective for short tasks.
- When introducing a value model, prioritize data-side investment and update-frequency tuning before touching the network architecture.
- Use doubly clipped importance truncation plus weight normalization as the default configuration, and monitor the weight distribution rather than just the mean.
- Ship context compression and advantage propagation masking together to avoid observation tokens contaminating gradients.
- On the scheduling side, bucket by length and set a backpressure ceiling, and write the “maximum allowed lag” as an explicit configuration item.
- Use a thousand steps as the minimum validation cycle; short runs do not reveal stability differences.
