Long-Horizon Agentic RL on 64 GPUs in Under 5 Days: Environment Filtering, Rollout Recipe, and a Unified Harness

    This article breaks down a public practice that completed full-parameter reinforcement learning for a long-horizon agent on 64 next-generation accelerators in under five days, starting from a sparse 321B-total-parameter base model with roughly 17.4B activated parameters per token. It explains why long-horizon agentic RL is usually expensive, then details the three pillars behind the result: treating environments as data with rolling pass-rate filtering, tuning the optimization recipe for long, stale, low-precision rollouts, and sharing one execution harness across training and evaluation. A reusable rollout checklist, limitations, and cost-accounting advice are included.

    1. Why Long-Horizon Agent Training Is Expensive and Hard

    The focus of large-model competition has shifted over the past two years from single-turn answer quality to the ability to complete long-horizon tasks. A long-horizon task requires the model to perform dozens or even hundreds of consecutive actions, such as orchestrating terminal commands, fixing defects at the repository level, or diagnosing build failures. These tasks have three inherent characteristics:

    1. Sparse rewards: success or failure can only be judged at the end of the task, with almost no immediate feedback on intermediate steps;
    2. A massive state space: each step’s observation includes command output, file diffs, and error stack traces, so the context expands quickly;
    3. Stale trajectories: generating one complete trajectory can take several minutes, and by the time it enters a gradient update, the policy has already advanced a number of steps.

    Together, these three factors make long-horizon agentic RL far more expensive to engineer than conventional alignment training. A common industry approach is to throw thousands of accelerators at it for weeks, pushing cost and energy consumption to a level most teams cannot afford. So the question that actually matters is not “can it be trained at all,” but: under a constraint of hundred-GPU-scale, day-scale compute, how do you push training efficiency onto the performance–cost Pareto frontier?

    2. Core Result: A Small Cluster Can Reach the Frontier

    A public practice offers an optimistic answer. Starting from a sparse base model with 321B total parameters and roughly 17.4B activated parameters per token, a research team used only 64 next-generation accelerators and less than 5 days to complete full-parameter reinforcement learning over all roughly 320B language parameters (including the multi-token prediction layers), freezing only the vision encoder and the sparse attention index module. The resulting agent reached a single-attempt pass rate of about 46% on mainstream terminal task benchmarks, in the same range as the strongest general-purpose reasoning models at the time, while the average cost per task was more than an order of magnitude lower than the highest reasoning-effort configuration. The same advantage carried over to two real software engineering benchmarks.

    What matters here is not any single trick, but the systematic combination of three things: environment filtering, the rollout recipe, and a unified harness. Each is unpacked below.

    3. Pillar One: Environments Are Data, and Task Difficulty Determines Signal Quality

    In long-horizon RL, the environment is not a “benchmark arena” but the primary source of training data. The team’s first lesson is to curate environments selectively rather than exhaustively, keeping every task inside a difficulty band where the model has a non-zero probability of success but is far from saturated.

    A practical metric for judging whether difficulty is right is the task-level pass-rate distribution. If a task’s pass rate is always 0, it is beyond the model’s current capability boundary and the gradient contains only noise; if it is always 1, the advantage function degenerates to zero and the samples are wasted. The ideal state is a pass rate spread across the 0.1–0.7 range that naturally shifts right as training progresses.

    The filtering logic looks schematically like this:

    1. # Pseudocode: environment admission and exit based on rolling pass rate
    2. def should_keep(task, stats, lo=0.05, hi=0.75, window=32):
    3. p = stats.pass_rate(task, window=window) # pass rate over the last N trials
    4. if p < lo: return False, "too_hard" # no usable signal
    5. if p > hi: return False, "saturated" # advantage degenerates to 0
    6. return True, "informative"
    7. # Maintain the task pool dynamically in the training loop instead of fixing it once
    8. for step in range(total_steps):
    9. batch = sampler.sample(pool, n=256)
    10. pool = [t for t in pool if should_keep(t, stats)[0]]
    11. pool += promote_from_holdout(batch, stats) # re-admit tasks whose difficulty has risen back into range
    12. train_step(batch)

    Two engineering details are worth noting. First, difficulty is dynamic: as the policy gets stronger, tasks that were once “too hard” move into the effective range, so you need a promotion/exit mechanism rather than a static list. Second, the verifier must be reliable: if task judging itself has a 5% false-positive rate, the model will quickly learn to exploit it, so it is advisable to run an adversarial spot check on the verification scripts before training.

    4. Pillar Two: An Optimization Recipe Tuned for Long, Stale, Low-Precision Rollouts

    Standard PPO-style algorithms rest on the assumptions that the policy and the sampling policy are approximately identical and that advantage estimates have low variance. Long-horizon agent trajectories violate both. The targeted adjustments usually cover four directions.

    1) Trajectory-level advantage with key-step weighting. Since the reward appears only at the end, propagate the advantage uniformly back through the whole trajectory, while assigning higher weight to “decision branch points” (such as whether to install a dependency or roll back a change) so that long-tail steps do not dilute the gradient.

    2) Staleness control and importance correction. There is a delay between sampling and updating, so explicitly record the policy version behind each trajectory and truncate the weights to prevent stale samples from causing distribution drift:

    1. # Pseudocode: importance weights with staleness truncation
    2. logw = old_logp - new_logp # sampling policy vs. current policy
    3. logw = torch.clamp(logw, -2.0, 2.0) # truncate to suppress the impact of stale samples
    4. loss = -(torch.exp(logw) * advantage).mean()

    3) Numerical stability under low precision. Mixed-precision training saves substantial memory and bandwidth, but the ratio terms in long-horizon RL are sensitive to numerical error. A common practice is to keep log-prob computation, advantage normalization, and optimizer state in higher precision, let only the main forward pass run in low precision, and apply global gradient-norm clipping.

    4) Layered organization of length and batches. Bucket and batch by trajectory length to reduce padding waste; at the same time, turn “generate–verify–update” into a pipeline so that idle time in the verification stage is covered by the next batch of generation. This is one of the key engineering levers for compressing the run to 5 days.

    5. Pillar Three: One Programming Harness for Both Training and Evaluation

    The third pillar is the most easily underestimated. Agent capability is determined jointly by the “model + runtime framework,” and if training uses one framework while evaluation uses another, the optimization target decouples from real performance and produces the false gain of “training scores rise, evaluation scores do not.” The team’s approach is to have model optimization, rollout sampling, and benchmark evaluation share the same programming execution framework, with a minimal and stable interface:

    1. reset(task_id) -> Observation
    2. step(action) -> (Observation, reward, done, info)

    Around this interface, the framework needs to provide a sandboxed file system with process isolation, command timeouts and resource limits, deterministic environment snapshots (for reproducibility and rollback), and structured logs and traces so failed trajectories can be attributed after the fact. The unified trace data can also feed back into environment filtering and difficulty tiering, forming a closed loop.

    6. A Reusable Implementation Checklist

    To reproduce similar efficiency on your own hundred-GPU cluster, proceed in this order:

    • Establish an evaluation baseline first: fix the harness and random seeds, run a small model end to end, and confirm there is no leakage in rewards or judging;
    • Then tier the environments: use the rolling pass rate to split tasks into too hard, effective, and saturated, and maintain the task pool dynamically;
    • Validate the recipe in small steps: at 1/8 scale, check whether staleness truncation, the precision strategy, and batch bucketing deliver stable gains;
    • Pipeline generation and verification: overlap the CPU-side sandbox with GPU-side training to raise effective cluster utilization;
    • Run full training and account for cost: use average cost per task rather than score alone as the primary metric, plot the performance–cost curve, and confirm you are on the frontier;
    • Verify capability transfer: run zero-shot transfer tests on external benchmarks such as repository-level defect repair to rule out overfitting to your own environments.

    7. Limitations and Risks

    Three boundaries should be stated objectively. First, full-parameter RL is highly sensitive to base model quality; if the base lacks basic tool-use and code-understanding ability, a small cluster cannot make up for it. Second, environment filtering and verifier design carry subjectivity, and a lax verifier directly amplifies the risk of reward hacking. Third, part of the cost advantage comes from the team’s self-deployed inference; if the absolute numbers are recomputed under external billing, they will change, but the trend of the relative frontier position still holds. In addition, long-horizon agents face non-model problems in real production environments, including permissions, data compliance, and operation rollback, so deployment should be backed by general cloud capabilities such as least-privilege sandboxes, operation auditing, and log monitoring with alerting.

    Overall, the most valuable lesson from this practice is that the bottleneck of long-horizon agentic RL has moved from compute scale to the fine-grained quality of data and engineering. Treat environments as data to be managed, design algorithms with staleness and low precision as first-class concerns, and anchor training and evaluation to the same execution framework: a hundred-GPU cluster can likewise push the performance–cost curve to the frontier.