Single-Trajectory Asynchronous Optimization: Efficient Sampling for Long-Horizon Agent Reinforcement Learning

    As reinforcement learning for large language models extends from short math-reasoning tasks to long-horizon agent workloads such as multi-turn code repair, tool calling, and cross-file engineering orchestration, traditional group-based sampling and fully synchronous training pipelines become bottlenecks. This article explains single-trajectory asynchronous optimization: a paradigm that generates only one immediately trainable rollout per input task and continuously streams samples to the trainer through an asynchronous pipeline. It covers the motivation (sampling cost, cluster idle time, and noisy advantage estimation), the core algorithmic components—Direct bilateral Importance Sampling (DIS), a reinforced value model with higher update frequency, frozen attention layers with MoE-projection-only tuning, and action-level advantage propagation that skips observation tokens—as well as system-level coordination, practical guidance, and key takeaways for applying the approach to your own RL training scenarios.

    1. Background: Why Single-Trajectory Asynchronous Optimization Is Needed

    As large-model reinforcement learning expands from simple mathematical reasoning to long-horizon agent tasks (such as multi-turn code repair, tool calling, and cross-file engineering orchestration), training pipelines face three major tensions:

    1. The cost dilemma of group-based sampling

    Group-based sampling methods, exemplified by GRPO, require generating multiple rollouts in parallel for the same input task, then using within-group relative advantages as the supervision signal. This works well on short-trajectory tasks, but a single agent trajectory often involves dozens of interaction turns and tens of thousands of tokens of context. If every task requires 8 or 16 complete trajectories, inference-side sampling cost scales multiplicatively. Constraints such as balanced rollout allocation and waiting for all trajectories in a group to finish further reduce the overall utilization of the training cluster.

    2. Idle resources in fully synchronous training

    Traditional synchronous RL chains “sampling → advantage computation → parameter update” into one large loop: while the inference cluster generates trajectories, most of the training cluster’s compute sits idle; during training, inference resources wait. For long-horizon tasks where a single sampling round can take hours, this idling is engineering-unacceptable.

    3. Noise amplification in advantage estimation on long trajectories

    Rewards in long-horizon tasks are sparse and delayed. The longer the trajectory, the less stable the credit assignment propagated from the final reward back to early decision points. Group-based sampling mitigates this through within-group comparison, but at the cost of expensive sampling volume.

    Single-trajectory asynchronous optimization is a systematic solution targeting all three pain points: each input task generates only a single rollout that can be used for training immediately, and sampling and training proceed continuously through an asynchronous pipeline. Sampling resources are no longer bound by the “group” concept, training data flows continuously, and a set of algorithmic designs keeps the off-policy deviation introduced by asynchrony under control.

    2. Core Design: Single-Rollout Sampling and Off-Policy Control

    2.1 From Within-Group Comparison to Single-Trajectory Training

    Under the single-rollout paradigm, each task produces only one trajectory, so within-group horizontal comparison is no longer possible. The advantage signal must come from a more reliable source: the value model. This brings two key changes:

    • Decoupled sampling: a trajectory enters the training queue as soon as it is generated, without waiting for peer trajectories. The scheduling granularity of inference resources shifts from “task groups” down to “individual trajectories.”
    • More frequent policy updates: the continuous data supply lets the policy model update in small, fast steps—but it also means the training data has drifted from the latest policy, i.e., the off-policy problem is explicitly amplified.

    The value proposition of the single-trajectory approach is: keep the off-policy impact within an acceptable range without degrading generalization. The theoretical explanation for improved generalization is that each update depends on only one independent trajectory, reducing the overfitting caused by highly correlated samples within the same batch in group-based sampling.

    2.2 Direct Bilateral Importance Sampling (DIS)

    In asynchronous training, the policy parameters used for updates have drifted several steps from the sampling parameters used to generate the trajectories. Classic importance sampling corrects this bias with the ratio r(θ), but on long trajectories, the token-level product of ratios leads to variance explosion or collapse.

    The idea behind Direct bilateral Importance Sampling is to introduce a trajectory-level weight calibration with bilateral clipping on both the new and old policies, constraining the weight in both the too-high and too-low directions, rather than simple one-sided clipping. This serves two purposes:

    1. When the deviation is still acceptable, preserve as much of the unbiasedness provided by importance correction as possible.
    2. When the sampling policy has drifted too far from the current policy—beyond what can be corrected—the gradient of the corresponding sample is effectively suppressed, preventing stale data from contaminating the current policy.

    An illustrative gradient-weight handling logic is shown below:

    1. def dis_weight(old_logp, new_logp, upper=1.2, lower=0.8):
    2. ratio = (new_logp - old_logp).exp() # token-level ratio
    3. traj_ratio = ratio.prod(dim=-1) # trajectory-level aggregation
    4. w = traj_ratio.clamp(lower, upper) # bilateral clipping
    5. penalize = (traj_ratio > upper) | (traj_ratio < lower)
    6. return w, penalize # zero out or downweight gradients of out-of-range samples

    2.3 Reinforcing the Value Model: Reducing Variance with a Single Trajectory

    Once within-group comparison is removed, the burden of variance control falls almost entirely on the value model. To address this, the method applies three targeted reinforcements on the value-model side:

    1. Increase the value model’s update frequency. For every policy update, the value model updates twice. The intuition: in an asynchronous pipeline the policy parameters move forward quickly; if the value model lags behind, the baselines it provides quickly become stale, and advantage estimation error grows. Letting the value model “run more diligently than the policy” keeps estimation bias low.

    2. Freeze the attention modules and optimize only the MoE projection layers. For mixture-of-experts large models, training the entire value head from scratch on a rolling basis easily introduces severe representation drift. Fixing the attention backbone and updating only the sparse projection layers preserves the backbone’s stable encoding of sequence structure while greatly reducing oscillation during value-function training; parameter count and memory overhead also drop significantly.

    3. Scale up the value model’s pretraining data. More thorough value pretraining gives the value model a reasonable prior over the reward distribution of agent tasks when RL starts, shortening the cold-start phase.

    2.4 Action-to-Action Advantage Propagation: GAE That Skips Observation Tokens

    Agent trajectories are naturally alternating “observation–action–observation–action” sequences. The observation portion (page snapshots, code file contents, tool return results) may occupy the vast majority of tokens in the context. Standard token-level GAE propagates advantage signals across all tokens, which causes:

    • The advantage to be diluted across massive observation tokens, leaving weak signals on the action tokens that actually need to take responsibility;
    • Semantic redundancy, since observation tokens are given by the environment and cannot be changed by the policy—computing learnable advantages for them is meaningless.

    The improvement: propagate advantage signals only between the action tokens generated by the model; observation tokens do not participate in token-level advantage accumulation. Credit assignment then acts directly on decision points, the signal-to-noise ratio on long trajectories improves markedly, and training variance drops further.

    3. System Coordination: The Asynchronous Pipeline and Scheduling Optimizations

    Algorithmic improvements need system-level support to translate into real throughput. The engineering pipeline of single-trajectory asynchronous optimization typically includes:

    • Trajectory-level data flow: each trajectory generated by the inference cluster is deduplicated, filtered, and scored, then immediately enqueued; the training side pulls batches asynchronously;
    • Joint scheduling of the router and the training system: for agent and asynchronous RL workloads, joint load balancing between the request-routing layer and the training system prevents some sampling shards from piling up trajectories while others sit idle;
    • Context compression: long-horizon agent trajectories contain large amounts of result-type text; targeted context compression before training preserves key decision context while reducing sequence length—this is one of the key levers for achieving multi-fold end-to-end throughput gains in long-horizon coding RL.

    Combined with a continuously evolving training framework, such a pipeline can remain stable over hundreds or even thousands of training steps without reward collapse or KL divergence, and consistently outperform group-based sampling baselines and their variants on agent coding and mathematical reasoning benchmarks.

    4. Practical Takeaways

    When adapting single-trajectory asynchronous optimization to your own RL training scenario, consider the following path:

    1. Estimate the sampling bottleneck first: if the rollout cost of your task far exceeds the gradient-computation cost (typical of long-horizon agent tasks), single-trajectory conversion yields the greatest benefit;
    2. Prioritize off-policy control: the deeper the asynchrony, the stricter the ratio monitoring and clipping mechanisms you need. It is recommended to continuously observe trajectory-level deviation and set a training circuit-breaker threshold;
    3. Don’t skimp on the value model: under the single-trajectory paradigm, value-model quality directly determines training success. Update frequency, parameter-freezing strategy, and pretraining adequacy all merit significant investment;
    4. Align credit assignment with decision points: advantage signals should land as much as possible only on the policy-controllable action tokens, avoiding dilution by massive observation tokens.

    In summary, single-trajectory asynchronous optimization—through the combined design of sampling-paradigm restructuring, bilateral importance sampling, value-model reinforcement, and action-level advantage propagation—achieves simultaneous improvements in training efficiency and generalization for long-horizon agent reinforcement learning, and represents one of the notable technical directions in the evolution of post-training infrastructure for large models.