Single-Trajectory Asynchronous Optimization for Agent Reinforcement Learning

    This article examines single-trajectory asynchronous optimization for reinforcement learning with long-horizon agents. It explains why group-based sampling becomes costly and unstable in long tasks, then outlines a one-trajectory-per-task design with immediate advantage computation and parameter updates. It also covers two-sided importance sampling, value-model support, advantage propagation that skips observation tokens, context compression, system-level coordination, cautions around reported metrics, and an engineering checklist for implementation and monitoring.

    Single-Trajectory Asynchronous Optimization for Agent Reinforcement Learning

    1. Challenges of Long-Horizon Agent Tasks for Reinforcement Learning

    An agent may need dozens of “observe, think, act” cycles to complete a single task. Group sampling methods, such as GRPO-style algorithms, generate multiple trajectories for the same task, multiplying generation overhead. Code execution and sandbox validation often take far longer than model forward computation. The entire group must wait for the slowest trajectory to finish before training can begin.

    The longer the trajectory, the more times policy parameters are updated during generation, and the more unevenly samples diverge from the current policy. Group reward variance fluctuates noticeably in long tasks, making advantage estimation unstable.

    2. Single-Rollout Sampling: Train as Each Trajectory Arrives

    The core choice in single-trajectory asynchronous optimization is to generate only one trajectory per input task. Once the trajectory is complete, the advantage is computed and parameters are updated immediately. The two workflows differ as follows:

    Group sampling: task → multiple trajectories → wait for the whole group → group-relative advantage → update

    Single-trajectory asynchronous: task → one trajectory → compute advantage immediately → update

    Comparison dimension Group sampling Single-trajectory asynchronous
    Generation overhead Multiple trajectories per task One trajectory per task
    Synchronization requirement Wait for the whole group Train samples as they arrive
    Source of advantage Relative comparison within the group Baseline provided by a value model
    Suitable boundary Short trajectories, immediate feedback Long-horizon, environment-interaction-heavy tasks

    This design shortens the time gap between a sample and the current policy and reduces waiting. The cost is that the group baseline disappears, so gradient variance for a single sample increases. Several supporting mechanisms are therefore needed to control bias and variance.

    3. Direct Two-Sided Importance Sampling

    In asynchronous training, the policy version that generated a sample differs from the policy version currently being trained. Importance sampling can correct this bias. Over long sequences, however, token-level probability ratios are multiplied consecutively and can easily produce extremely large or small values. Two-sided clipping limits each token ratio between lower and upper bounds, preventing a few tokens from dominating the gradient.

    An illustrative implementation is shown below:

    1. ratio = torch.exp(logp_new - logp_old)
    2. w = torch.clamp(ratio, lower_bound, upper_bound).detach()
    3. loss = -(w * advantage * logp_new).mean()

    The weight w here does not backpropagate gradients; gradients are produced only through logp_new. Without detach, gradients would be incorrectly added to the weight term, and training results would deviate from expectations.

    The lower and upper bounds require tuning. A common practice is to set the interval around 1, for example 0.5 to 2, but this is only a starting point. Narrowing the interval reduces variance while increasing bias. If the interval is too wide, individual tokens can still dominate updates. If gradient norm spikes, loss spikes, or policy entropy drops rapidly during training, it usually indicates that the clipping interval or the degree of asynchrony needs adjustment. It is recommended to continuously monitor the proportion of clipped tokens. If this proportion remains high for a long time, the asynchronous bias has exceeded an acceptable range.

    4. Supporting Design for the Value Model

    Without a group baseline, the value model must handle more estimation work. The source article proposes three practices:

    1. Increase the value model update frequency, for example two value updates for each policy update.
    2. Freeze the attention modules and train only the MoE expert projection layers.
    3. Expand the pretraining data scale for the value model.

    Whether these practices are effective depends on the specific model and compute resources. Higher update frequency increases computational overhead. Freezing attention parameters can reduce fluctuation, but it may also limit the value model’s expressiveness. The source article does not provide corresponding ablation experiments, so teams should treat these as candidate approaches to be validated. During validation, compare advantage estimation variance and final metrics under different update ratios, such as 1:1, 1:2, and 1:4.

    5. Advantage Propagation in Multi-Turn Trajectories

    An agent trajectory contains two types of tokens. One type is observation tokens returned by the environment, such as code execution output and tool results. The other is action tokens generated by the model, such as decisions and code. Computing token-level GAE on the observation portion both consumes compute and introduces environment noise into the advantage signal.

    The source article’s approach skips GAE for observation tokens and propagates advantage only between actions. Observations are treated as a “short circuit,” and advantage is passed back along action-to-action links. This has two benefits. First, observation tokens often account for most of the sequence, so skipping them can significantly reduce computation. Second, gradients are attributed only to the model’s own decisions, making credit assignment clearer.

    Implementation requires clarifying one point: after skipping observations, how the discount factor and time interval between actions are defined. If these are not clearly defined, the advantage may deviate from the true return structure.

    6. Context Compression

    The context of long-horizon tasks may reach tens of thousands of tokens. A common compression strategy is to retain complete records for the most recent several rounds, summarize earlier history, and set a length threshold that triggers compression. The number of retained rounds and the threshold need to be determined according to task length and context window.

    There is also a training consideration. The compressed context must remain consistent with the context used during sampling. Otherwise, importance ratios will be distorted, and bias correction will fail.

    7. System-Level Coordination

    The throughput bottleneck in asynchronous training often appears on the system side. In MoE models, load imbalance caused by token routing can amplify when combined with asynchronous pipelines. Jointly scheduling the request dispatch layer and the training execution layer can reduce expert hotspots and make the overall rhythm more even. Single-trajectory train-as-you-go also allows generation, advantage computation, and parameter updates to interleave on a per-trajectory basis, reducing global synchronization waits.

    The source article reports that in long-horizon code reinforcement learning tasks, end-to-end training throughput improved by more than 2.3x and training ran stably for over a thousand steps. These figures come from public reports. The source article does not provide hardware configuration, model scale, task set, baseline methods, or statistical methodology, so they cannot be independently verified. When citing them, they should be identified as reported results and not treated as general expectations.

    8. Note on the Source Article’s Evaluation Data

    The AIME 2025 accuracy and SWE-Bench Verified pass rate mentioned in the source article likewise lack details on the model, sampling count, evaluation protocol, and tool configuration. This article does not restate those specific numbers. To compare different methods, the following should be unified: the calculation method for pass@1 or avg@k, sampling temperature, maximum number of interaction rounds, tool permissions, and number of random seeds.

    9. Practical Checklist for Engineering Teams

    1. Sampling paradigm: first measure trajectory length and environment time for the task. If environment time is much higher than model generation time, single-trajectory asynchronous optimization is more likely to bring throughput gains. If tasks are very short, the relative advantage signal from group sampling may be more stable.
    2. Bias control: record the staleness of each sample, that is, the difference between the parameter version at generation time and the current version. Set an upper limit; discard samples that exceed the limit or reduce their weight.
    3. Importance ratios: monitor the proportion of clipped tokens and the quantiles of the ratio distribution. If the proportion remains high, reduce the degree of asynchrony or lower the update step size.
    4. Critic update frequency: start from 1:1, gradually try 1:2, and compare the variance of advantage estimates and final metrics.
    5. Queues and rollback: monitor queue length and generation latency, and set a queue upper limit. If training diverges, roll back to the last stable checkpoint.