Long-Horizon Agent RL on Hundred-GPU Clusters
Long-horizon agents now run hours of terminal work and software engineering, with hundreds of tool calls per task. On hundred-GPU clusters the bottleneck is wasted samples, not whether training starts. This article outlines a reusable path: full-parameter updates of the language backbone, reliable rewards from well-filtered environments, optimization for long, stale, low-precision trajectories, and a shared agent runtime for training and evaluation so pass rate and cost per task move together toward a performance–cost Pareto frontier.
Long-horizon agents are moving from “fix a local defect” to hours of continuous terminal work and software engineering. They read repositories, edit code, run tests, inspect logs, and decide the next step. A single task often includes hundreds of tool calls. For most teams, reinforcement learning is no longer blocked by “can we run the model,” but by how much accelerator time a failed sample burns. Frontier labs can amortize trial and error on huge clusters. A hundred-GPU cluster that still uses short-trajectory, high-throughput recipes will spend compute on useless replay.
This article describes a reusable engineering path: fully update the language backbone, use environments of appropriate difficulty for stable reward, redesign optimization for long, stale, low-precision trajectories, and share one agent runtime for training and evaluation. The goal is not to stack absolute scores, but to improve task pass rate and cost per task together, staying close to the performance–cost Pareto frontier.
Why long-horizon sampling is expensive
In short-answer RL, a trajectory often ends in seconds. Failures are cheap, and large-scale parallel luck can work. Long-horizon agents differ: environment state accumulates with commands, context keeps growing, and credit assignment spans many steps. Tool timeouts, test misjudgments, context truncation, or mid-trajectory policy drift can distort the entire trajectory’s reward. Distorted samples still occupy inference GPUs, environment nodes, and replay storage.
Efficiency comes first from sampling fewer wasted trajectories, then from sampling faster. A hundred-GPU cluster’s advantage is not peak throughput, but whether every hour of gradients corresponds to real, reproducible task progress.
Filter the environment into a reliable signal source
The most common failure in agent RL is reward that does not match real capability. Tasks that are too easy almost always succeed, and gradients vanish. Tasks that are too hard almost always fail, so the policy cannot tell “almost” from “cannot.” Terminal and coding tasks are easy to game with surface metrics: a command exit code of 0 does not mean the bug is fixed, and tests can pass by bypassing assertions.
Useful filtering principles include:
- Difficulty tiers. Split tasks by base-model pass rate into easy, medium, and hard. In mid-training, sample mainly the “sometimes succeeds” band so advantage estimates have variance without being too sparse.
- Verifiable reward. Prefer outcomes that can be judged automatically—hidden tests, static checks, and behavioral constraints all holding—rather than the model claiming “done.”
- Replayable trajectories. Pin dependency versions, random seeds, and working directories so the same action sequence reproduces the same environment state. Otherwise offline replay cannot support stable updates.
- Remove reward hacks. Penalize or drop shortcuts such as deleting tests, changing assertions, or retrying until a chance pass.
More environments are not better. A hundred-GPU cluster needs a small set of tasks with clean signal and difficulty matched to the current policy, not dumping heterogeneous benchmarks into the sampler as-is.
What to freeze under full-parameter updates
Starting from a strong base and doing full-parameter RL, usually update the language parameters that plan and generate code. If the model has auxiliary heads such as multi-token prediction that participate in decoding, train those as well so the main model and heads do not diverge. Freeze modules that do not participate in this task’s decisions—vision encoders, retrieval indexes, and similar—to save memory and optimizer state.
Memory pressure comes mainly from optimizer state and long-context activations, not from parameters themselves. In practice, use parameter sharding, activation recomputation, and sequence parallelism. Split ultra-long trajectories at tool boundaries into alignable segments; run exact backward only inside a segment and pass credit across segments with truncated value estimates. Frozen modules must keep the same version in training and evaluation, or distribution shift will be mistaken for policy regression.
A recipe for long, stale, low-precision replay
Long-horizon sampling is almost always “stale”: by the time a three-hour trajectory finishes, the policy has already updated several times. Importance sampling under an on-policy assumption then explodes or collapses. Low-precision inference raises sampling throughput, but log-probs that disagree with training precision amplify ratio error.
Design the recipe in pieces rather than only tuning a learning rate:
- Control off-policy degree. Shorten the gap between sampling and updates, or decay weights by trajectory age. Dropping samples that are too old often costs fewer GPUs than forcing a correction.
- Clip importance ratios. Bound the ratio and monitor the effective sample fraction. If that fraction stays too low, reduce update steps per iteration instead of hiding the problem with a larger batch.
- Separate sampling precision from training precision. Sampling may use lower precision for throughput, but replay must store log-probs consistent with the training graph, or recompute log-probs of key tokens at training precision before the update. Do not mix two numeric stacks when estimating advantage.
- Add process signals to sparse terminal reward. Pass/fail at the end remains the main reward, but dense terms—test progress, whether edits touch relevant files, whether the agent loops on the same command—can ease credit assignment after a hundred steps. Keep dense weights small so the policy does not optimize for looking busy.
- Group baselines before a hand-tuned value net is reliable. Sample the same task multiple times and use the in-group mean return as a baseline to cut variance. When group size is limited by GPU count, keep comparisons under the same prompt rather than mixing unrelated tasks into one large batch.
Illustrative weight logic:
ratio = exp(logp_train - logp_behavior)ratio = clip(ratio, 1 - eps, 1 + eps)age_w = exp(-lambda * staleness_steps)sample_w = ratio * age_w * valid_maskloss = -advantage * sample_w * logp_train
The point is not a fixed hyperparameter, but three monitors: whether ratios pile up at the clip bounds, whether age weights drive most samples near zero, and whether advantages share the sign of final success or failure. If any of the three is out of control, stop updates, inspect the environment and log-probs, then resume.
Training, optimization, and evaluation must share a runtime
Long-horizon scores depend heavily on the runtime: how the working directory is provided, how tests are triggered, timeouts, whether failure messages are fed back, and whether network installs are allowed. If training uses one interaction protocol and evaluation another, the policy overfits training-framework bugs and pass rates look inflated after launch or a benchmark change.
A shared framework should at least unify:
- Tool list and parameter schemas, including read file, edit file, run command, and inspect test output.
- Context budget and truncation so training does not ingest full logs while evaluation keeps only a summary.
- Timeouts, retries, and isolation: each task uses an independent working copy so samples do not contaminate each other.
- Cost accounting. Cost per task should include model inference, environment execution, and failed retries, not only output tokens from a successful run. Self-hosted and hosted API prices should not be compared directly unless hardware occupancy is converted to the same unit.
Evaluation reports should give mean pass rate over multiple trials, variance, and mean cost. A single peak does not show whether the recipe is stable. For a performance–cost curve, a log cost axis is more appropriate because inference intensity, number of samples, and context length can move cost across orders of magnitude. A Pareto improvement raises pass rate without a large cost increase, or cuts cost clearly at similar pass rate.
Scheduling on a hundred-GPU cluster
Split GPUs into a sampling pool and an update pool; adjust the ratio with trajectory length. When trajectories are long, sampling should take most of the GPUs or update GPUs sit idle. Scale environment nodes separately from accelerators: tests and compiles often consume CPU and disk, not matrix compute.
Checkpoints must resume from mid-trajectory. If a three-hour task only writes at the end, a failure wastes the whole run. Periodically flush policy, optimizer, and identifiers of unfinished trajectories by step count or wall clock. After restart, drop half-finished trajectories that cannot continue so incomplete returns do not enter replay.
Logs should at least record task ID, trajectory age, effective sample fraction, share of clipped ratios, terminal reward, tool-failure types, and wall-clock time per task. In weekly experiments, these curves explain recipe health better than a final leaderboard.
A low-to-high risk rollout order
Advance by risk rather than starting with full-parameter updates on every benchmark.
- Freeze the runtime and confirm base-model pass rate and cost on a few verifiable tasks.
- Filter environments and audit rewards without changing the model; see whether the wasted-sample rate drops.
- Run small-step RL with most modules frozen to validate log-probs, age weights, and group baselines.
- Then open full-parameter updates of the language backbone, keeping the evaluation framework unchanged.
- Move the same recipe to adjacent software-engineering tasks and check whether gains come from overfitting one test suite or from more stable multi-step decisions.
Transfer failure usually means a hole in reward or the framework, not a learning rate that is “almost right.” Go back to trajectory replay and inspect tool sequences on failures instead of adding more GPUs.
Conclusion
A hundred-GPU cluster that approaches the Pareto frontier for long-horizon agents does not linearly scale a short-task recipe. Three things matter: put each task at a difficulty that yields reliable gradients; accept that trajectories are long, policies stale, and sampling precision low, and bound off-policy error accordingly; use one runtime through optimization, training, and evaluation so pass rate and cost per task can be compared. When compute is limited, cutting wasted hours decides the outcome more than peak throughput of a single sample.
