Training Long-Horizon Agents on 100 GPUs: A Low-Cost RL Engineering Practice

    This article examines why reinforcement learning for long-horizon agents is so expensive and how a recent open practice trained a 300B-parameter MoE model to near-frontier terminal-agent performance using only 64 flagship GPUs in under five days. It breaks down the three pillars behind the result: carefully curated RL environments with reliable reward verification, a long-rollout training recipe addressing staleness and numerical stability, and a unified agent harness shared across training, serving, and evaluation—offering a replicable playbook for small and mid-sized teams.

    1. Why Long-Horizon Agent Training Is So Expensive

    Large-model agents are evolving from “completing one code completion” to “working continuously for hours.” These long-horizon agents operate in a real or simulated terminal environment, executing hundreds of tool calls in a row—reading and writing files, running tests, debugging errors, modifying code, and verifying changes again. A single task trajectory can span more than three hours.

    This capability is acquired primarily through reinforcement learning (RL), but training costs are extremely high for three reasons:

    1. Each sample is expensive. One training sample is one complete long-horizon attempt. If the agent fails mid-way due to an environment fault, verifier misjudgment, or scheduling issues, hours of GPU time and compute are wasted.
    2. High compute barrier. Frontier labs routinely scale RL across thousands of GPUs—a path that mid-sized teams simply cannot replicate.
    3. Hard-to-control signal-to-noise ratio. Long-sequence rollouts often suffer from sparse rewards, trajectory staleness, and low numerical precision; a single misstep can cause training to collapse or fail to converge.

    The core question therefore becomes: can a ~100-GPU cluster train a long-horizon agent that sits on the Pareto frontier of both performance and cost, within a reasonable time and budget?

    2. A Practice Worth Noting: 64 GPUs, 5 Days, a 300B-Class Model

    A recent public study answered this affirmatively. The team started from a 300B-scale Mixture-of-Experts (MoE) base model (roughly 320B total parameters, about 17B activated per token) and performed full-parameter RL training. Training covered all language-model parameters, including the multi-token prediction layers, while freezing the vision encoder and sparse attention indexing modules to reduce overhead.

    The results stand out on four dimensions:

    • Performance: Pass@1 (single-attempt pass rate) of about 46% on a mainstream terminal-operation benchmark, on par with several closed-source flagship models.
    • Cost: Inference cost per task is roughly 30× lower than comparable high-performing closed-source solutions at their highest reasoning-effort setting.
    • Generalization: The performance gains transfer to two mainstream software engineering (SWE) benchmarks, showing the capability is not overfit to a single benchmark.
    • Efficiency: The entire run used only 64 flagship GPUs and took less than five days, with the team publishing the full training recipe.

    On the performance–cost plane, this shifts the Pareto frontier significantly down and to the right: the same budget buys a higher pass rate, or the same pass rate costs only a fraction as much.

    3. Methodology, Part 1: Carefully Curated RL Environments for Signal Quality

    The upper bound of RL training is determined by environment quality. Instead of “stacking more tasks,” the team filtered environments around three principles:

    1. Reasonable difficulty stratification. If tasks are too hard, the model fails almost everything, rewards degenerate to all zeros, and no gradient signal emerges. If tasks are too easy, rewards saturate and the model learns nothing new. The ideal environment set sits near the boundary of the model’s current capability—“reachable but requiring effort”—with curriculum-style scheduling that adapts as the model improves.

    2. Reliable reward verification. Final judgment for long-horizon tasks typically relies on test cases or state checks. Verifiers must be deterministic and reproducible, impossible to circumvent via reward hacking, and capable of attributing failure causes (distinguishing “the model got it wrong” from “the environment itself failed”). This required combining manual review with automated audits to remove tasks with unstable verification.

    3. Coverage of real-world workflows. Environments should simulate real engineering scenarios—multi-file edits, dependency installation, test-driven fixes, log troubleshooting, and so on—so the training distribution doesn’t diverge from the deployment distribution.

    4. Methodology, Part 2: An RL Recipe for Long Rollouts

    Long-horizon RL differs fundamentally from traditional short-sequence RL. The recipe addresses four pain points:

    • Long rollout durations and scheduling. A single trajectory can take tens of minutes to hours. If parameter updates wait for all rollouts to finish, samples become severely stale (excessively off-policy). The solution combines partial rollouts, asynchronous sampling, and trajectory chunk replay so that generation and training pipeline overlap, while keeping policy staleness within an acceptable range.
    • Low precision and numerical stability. Full-parameter training of a 300B-scale MoE model is sensitive to precision. It requires careful trade-offs among optimizer states, gradient accumulation, and communication compression to prevent mid-run divergence.
    • Credit assignment. Hundreds of steps produce only a single terminal reward. Convergence must be accelerated with process-level signals (such as intermediate test results) or improved advantage estimates.
    • Fault tolerance and resumable training. Environment failures are inevitable. The training system must identify environment failures and treat them separately from model failures so they don’t pollute the reward signal, while supporting task-level retries.

    5. Methodology, Part 3: One Unified Agent Framework for Training, Inference, and Evaluation

    The third key engineering decision: training, model serving, and evaluation all use the same agent runtime (harness). This yields three direct benefits:

    1. Eliminating train–inference inconsistency. If training uses one tool-calling protocol while evaluation uses another, model behavior drifts and scores cannot be trusted. A unified harness guarantees identical tool definitions, context management, timeout, and retry logic on both sides.
    2. Amortizing engineering cost. Sandboxing, filesystem snapshots, execution-environment images, log collection, and similar infrastructure are maintained only once; when something breaks, only one place needs debugging.
    3. Evaluation feedback feeds training. Failure cases from the same harness can be seamlessly converted into new training tasks or verifier fixes, forming a data flywheel.

    A typical harness execution loop can be summarized in pseudocode:

    1. while not done and steps < MAX_STEPS:
    2. obs = agent.observe(env) # Get terminal output / file state
    3. action = model.generate(obs) # Generate the next command or edit
    4. result = env.execute(action) # Execute in sandbox, capture stdout/exit code
    5. trajectory.append(obs, action, result)
    6. reward = verifier.check(env) # Score based on final state and test cases

    6. Lessons for Small and Mid-Sized Teams

    The most important takeaway from this practice is not any single number, but the proof that compute scale is not the only variable in long-horizon agent RL. Teams can extract a replicable path:

    • Prioritize investment in environments and verifier quality over blindly expanding the task pool.
    • Design sampling and training pipelines specifically for long trajectories, controlling staleness and ensuring numerical stability.
    • Use one unified harness across training and evaluation to reduce consistency risks and maintenance overhead.
    • On large MoE models, freezing non-core modules and training only the language parameters is an effective way to control memory and communication overhead.

    For teams with compute budgets in the ~100-GPU range, training a frontier-competitive long-horizon coding and terminal agent has shifted from “impossible” to “an engineering problem”—and engineering problems can always be decomposed and solved.