Asynchronous Single-Trajectory Optimization for Long-Horizon Agent Reinforcement Learning
This article explains how Single-Trajectory Asynchronous Optimization (SAO) adapts reinforcement learning to long-horizon AI agents. It covers the limitations of group-based sampling, importance-ratio clipping, value-model update schedules, selective parameter training, action-only advantage propagation, context compression, and asynchronous pipeline design. It also reviews reported benchmark results and provides practical guidance for deploying and monitoring the approach.
1. Why Long-Horizon Agents Are Difficult to Train
As large language models evolve from single-turn question answering to agent-based workflows, the training objective changes from “produce a correct answer” to “complete a multi-step task.” A single execution trajectory may include dozens of tool calls, code modifications, and environment feedback, with a total length that can easily reach tens of thousands of tokens.
Reinforcement learning in this setting faces three major challenges:
- High sampling costs: Each task may require a complete interaction with the environment.
- Long trajectories and delayed rewards: Credit assignment becomes difficult when rewards arrive only after many steps.
- Asynchronous off-policy training: When training and sampling run asynchronously, the data used for updates may no longer be generated by the current policy. The resulting off-policy bias can accumulate over time.
2. From Group-Based Sampling to Single-Trajectory Sampling
Group Relative Policy Optimization (GRPO) is a common approach in which multiple outputs are sampled for the same input task. Relative differences in group rewards are then used to estimate advantages, eliminating the need for a separate value network.
This approach is stable for short-answer tasks, but it has two limitations in agent environments. First, each task must be executed multiple times, causing environment costs to grow linearly with the group size. Second, all samples in a group must be completed before their advantages can be calculated together, which makes integration with asynchronous pipelines difficult.
Single-Trajectory Asynchronous Optimization (SAO) takes the opposite approach. Each input task generates only one rollout, which is immediately placed into the training queue.
This creates two benefits:
- The sampling budget is distributed across more distinct tasks, which can improve generalization.
- Data does not need to wait for other samples in the same group, allowing generation and training to operate independently.
The trade-off is higher variance for each individual sample. Additional mechanisms are therefore required to keep training stable, as described below.
3. Core Mechanisms
3.1 Direct Two-Sided Importance Sampling
In asynchronous training, the behavior policy used for sampling differs from the policy currently being optimized. Importance sampling uses probability ratios to reweight gradients and correct this distribution shift. However, extremely large ratios can cause variance to increase sharply.
Direct two-sided importance sampling (DIS) constrains both the lower and upper sides of the ratio, clipping extreme weights to a reasonable range. The goal is to balance bias and variance: overly tight clipping introduces systematic bias, while overly loose clipping can make training unstable.
In practice, clipping thresholds should be adjusted according to trajectory length and asynchronous delay. Teams should also monitor the proportion of samples affected by clipping.
ratio = exp(logp_current - logp_behavior)ratio = clip(ratio, low, high) # Two-sided clippingloss = -(ratio * advantage).mean()
3.2 Value-Model Update Frequency
Advantage estimation for single-trajectory data depends on the value model. If the value model is updated more slowly than the policy model, its estimates will lag behind the current policy distribution, potentially shifting the direction of policy updates.
One possible strategy is to increase the value-model update frequency. For example, the value model can be updated twice for every policy update. More frequent value updates help the value estimates track changes in the policy distribution and reduce gradient noise.
The additional updates also increase compute costs, so teams must balance training throughput against estimation accuracy.
3.3 Freezing Attention and Training Only MoE Projection Layers
When value-model training is highly unstable, a conservative strategy is to freeze the attention parameters and optimize only the projection layers in the Mixture-of-Experts (MoE) structure.
The attention parameters are responsible for much of the learned representation. Freezing them keeps the value model’s representation space more stable, while the remaining parameters focus on fine-tuning the output mapping. This reduces the degrees of freedom in the parameter space and can lower training variance.
Whether this approach is suitable for other model architectures must be verified through ablation experiments on the target model.
3.4 Propagating Advantages Only Between Actions
Agent trajectories contain two types of tokens:
- Action tokens generated by the model
- Observation tokens returned by the environment
Observation tokens are not the result of policy decisions. If generalized advantage estimation (GAE) is applied to every token, environmental noise may be incorrectly attributed to positions that are unrelated to the model’s actions.
Skipping observation tokens and propagating advantage signals only between actions makes credit assignment more closely reflect the model’s own decisions.
3.5 Multi-Turn Trajectories and Context Compression
Long trajectories can exceed the model’s context window. Context compression shortens the input through methods such as summarization and trimming historical tool outputs, allowing subsequent steps to continue normally.
For reinforcement learning, the trajectory before and after compression must remain consistent during reward calculation and advantage propagation. Otherwise, the model may learn biases introduced by the compression process.
Training systems should record compression operations in the trajectory metadata to support replay and analysis.
4. Engineering an Asynchronous Pipeline
A complete system typically contains three components:
- A routing layer that distributes tasks and collects trajectories
- A sampling cluster that performs environment interactions
- A training cluster that consumes trajectories and updates model parameters
These components communicate through queues and can be scaled independently.
Load balancing is a key scheduling challenge. Long and short trajectories can have significantly different execution times. With simple round-robin scheduling, some workers may remain idle for extended periods.
Possible solutions include:
- Bucketing tasks according to their estimated lengths
- Reserving dedicated resources for long-running tasks
- Dynamically adjusting batch size based on the rate at which data arrives at the trainer
while not stop:task = scheduler.next_task(estimated_length)traj = rollout_worker.run(task, policy_version=v)buffer.push(traj) # A single trajectory can enter the queueif buffer.ready(batch_size):batch = buffer.pop(batch_size)trainer.update(batch) # The trainer consumes data and updates parametersv += 1
5. Results and Interpretation
Public reports indicate that this approach outperforms group-based baselines on both mathematical reasoning and software engineering issue-resolution benchmarks.
On a challenging mathematical competition benchmark, the single-trajectory method achieved an accuracy of 97.3%, compared with 84.2% for the group-based baseline. On a software engineering issue-resolution benchmark, it achieved an accuracy of 29.8%.
The reports also state that the method can train stably for 1,000 steps. In long-horizon coding reinforcement learning scenarios, scheduling optimizations increased end-to-end training throughput by more than 2.3 times.
These figures should be interpreted carefully:
- Results from different benchmarks cannot be compared directly. Only relative differences within the same benchmark are meaningful.
- Throughput improvements depend on hardware, concurrency, and task distribution. They should not be treated as universal results.
- The number of stable training steps reflects process robustness, but it must be evaluated together with final capability metrics.
6. Deployment Recommendations
- Start with small-scale tasks and compare single-trajectory and group-based approaches. Track variance, the proportion of off-policy data, and the proportion of clipped samples.
- Monitor value-model loss and advantage distributions. If they fluctuate sharply, first reduce the update step size or increase the number of value-model updates.
- Configure timeouts and retry policies for environment interactions. Clearly define whether failed trajectories should enter the training queue to avoid introducing bias.
- Save the policy version, compression records, and reward details for every trajectory to support attribution and troubleshooting.
7. Conclusion
Single-Trajectory Asynchronous Optimization reduces the reinforcement learning sampling unit from “a group of outputs” to “one trajectory.” It maintains training stability through clipped importance sampling, controlled value-model update schedules, and constrained advantage propagation.
For long-horizon agent tasks, this design can reduce environment costs, improve asynchronous efficiency, and preserve strong generalization performance. In deployment, tuning should be guided by measurable metrics, and the approach should be thoroughly validated on the target model and task distribution.
