Efficient Training Practices for Long-Horizon Agentic Reinforcement Learning
This article explains why long-horizon AI agents are expensive to train rather than to run, and how teams operating around a hundred accelerators can push toward the performance-cost Pareto frontier. It covers full-parameter language-side RL on a sparse Mixture-of-Experts base model, environment filtering by verifiability and pass-rate difficulty, an RL recipe for long, stale, low-precision rollouts, a unified agent harness shared by training and evaluation, engineering constraints on memory, communication and fault tolerance, and a reusable checklist for getting started.
1. Why Long-Horizon Agents Are Expensive to Train, Not to Run
Long-horizon agents are pushing task boundaries from “fix one bug” to hours of continuous terminal work and software engineering. The defining trait of these tasks is that a single sample is not one question-answer exchange but one complete attempt: the model calls tools across many turns, reads and writes files, executes commands, observes errors and self-corrects, often reaching hundreds of interactions and hours of wall-clock time.
This creates a cost structure problem that is easy to underestimate: the truly expensive part is usually not the final inference pass but the repeated trial and error of the reinforcement learning stage. Frontier labs can scale RL across thousands of accelerators, while most teams have clusters of only about a hundred. At that scale, one failed rollout wastes hours of GPU time, and if the environment is noisy and rewards are sparse, training degrades into “sampling useless experience with expensive compute.”
So for a hundred-GPU-class cluster to approach the performance-cost Pareto frontier, the core lever is not more hardware but converting every unit of compute into effective training signal. The rest of this article breaks that proposition into five actionable areas.
2. Key Prerequisite: Full-Parameter RL Starting From the Base Model
The practical starting point is a sparsified base model (a Mixture-of-Experts architecture) with roughly 300 billion total parameters and about 17 billion activated parameters per token. The team chose full-parameter RL on the language side, training all roughly 320 billion language parameters (including the multi-token prediction layer) while freezing the vision encoder and the sparse attention indexer.
The reasoning behind this trade-off:
- The bottleneck for long-horizon agents lies in the decision and tool-use policy, not in visual understanding or the index structure, so freezing non-critical modules substantially reduces memory and communication pressure.
- Full-parameter updates genuinely change the model’s action priors, avoiding the limited policy drift that comes from tuning only lightweight adapter layers.
- Keeping the multi-token prediction layer in training helps stabilize planning consistency over long sequences.
An illustrative training configuration (pseudocode, structure only):
# Illustrates training scope and freezing policy only; not any specific product APItrainable = ["language_layers", "mtp_head"]frozen = ["vision_tower", "sparse_attn_indexer"]for step in range(total_steps):batch = rollout_buffer.sample(group_size=G) # sample multiple trajectories per taskadv = group_relative_advantage(batch) # group-relative advantage, less reliance on absolute rewardloss = policy_loss(batch, adv) + kl_penalty(policy, ref)optimizer.step(loss, params=trainable) # update language-side parameters only
3. Area One: Environment Filtering for the Right Difficulty and Reliable Signal
The first-order problem in long-horizon RL is reward signal quality. The approach here is to carefully curate agentic RL environments rather than blindly expanding the task pool. Actionable filtering criteria include:
- Verifiability: a task must have an objective success criterion (unit tests passing, command return codes, file-state assertions) to avoid the noise of subjective scoring.
- Difficulty stratification: estimate pass rates through repeated sampling with the base model, discard tasks with pass rates that are too high (no information) or too low (almost all failures, sparse gradients), and keep the intermediate difficulty band.
- Reproducibility: pin container images, dependency versions and network policies to reduce “same task, different result” environment drift.
- Bounded duration: set wall-clock and tool-call limits per task so a few extremely long samples do not drag down sampling throughput.
A simplified difficulty filter:
def keep(task, p_hat, lo=0.05, hi=0.8):# p_hat: empirical pass rate of the base model on this taskreturn task.verifiable and lo <= p_hat <= hi and task.max_walltime <= LIMIT
The payoff is that each rollout is more likely to land in a region with both positives and negatives, which lowers the variance of the group-relative advantage estimate, so a hundred-GPU cluster does not have to compensate for missing signal with massive sampling.
4. Area Two: An RL Recipe for Long, Stale, Low-Precision Rollouts
Three practical constraints define the long-horizon setting: trajectories are long, data is stale (high off-policy degree), and inference and training precision differ. The corresponding recipe:
- Long sequences: use segmented advantage estimation and trajectory-level discounting to weaken the dominance of a single terminal reward; reweight key steps in very long trajectories to highlight decision branch points.
- Stale data: replace the absolute value baseline with group-relative advantage, pair it with a smaller update step size and periodic reference-model refreshes to suppress drift from stale policies.
- Low-precision sampling: inference commonly uses lower precision for throughput while training keeps higher precision; align numerics and apply temperature correction before loss computation so precision mismatch is not misread as policy degradation.
Illustration:
adv = (reward - reward.mean(group)) / (reward.std(group) + 1e-6)loss = -min(ratio * adv, clip(ratio, 1-e, 1+e) * adv).mean() + beta * kl
On the engineering side, decouple sampling and training into an asynchronous pipeline: the inference cluster continuously produces and labels trajectories while the training cluster consumes them and updates weights, with version numbers capping how stale the data can get.
5. Area Three: A Unified Coding Harness Shared by Training and Evaluation
The most common hidden bug in long-horizon agents is a mismatch between the tool interfaces used in training and those used in evaluation, which inflates offline metrics and collapses in production. The emphasis here is that model optimization, training and evaluation all share the same harness, which matters because:
- Interface consistency: unified signatures for file reads and writes, command execution, retrieval and patch application prevent the policy from overfitting to one private wrapper.
- State consistency: identical container initial states, timeouts, retries and log collection keep rewards reproducible.
- Observability: uniformly recording every tool call, return code, latency and token consumption makes it easier to tell whether the policy is wrong or the environment is.
Minimal harness structure:
class Tool: ...class RunResult:success: boolsteps: intwalltime: floattokens: intdef run_episode(policy, task, tools, limits) -> RunResult:state = task.reset()for t in range(limits.max_steps):action = policy(state, tools.schema())obs, done = tools.execute(action, timeout=limits.step_timeout)state = state.step(action, obs)if done or state.verified():return RunResult(state.verified(), t+1, state.walltime, state.tokens)return RunResult(False, limits.max_steps, state.walltime, state.tokens)
6. Areas Four and Five: Engineering Constraints of Full-Parameter Training and the Evaluation Loop
Full-parameter RL at the 300-billion scale on a hundred-GPU cluster concentrates engineering constraints in memory, communication and fault tolerance:
- Memory: shard parameters, gradients and optimizer states, combined with activation recomputation; freezing the vision tower and indexer saves a considerable amount of memory.
- Communication: use a hybrid split of tensor, pipeline and data parallelism, overlapping long-sequence attention computation with expert-routing communication.
- Fault tolerance: long tasks must support checkpoint resumption and reuse of persisted rollout results, so a single failure does not force hours of re-running.
The evaluation loop is equally important: measure stability with Pass@1 averaged over multiple trials on several terminal and software engineering benchmarks; because the model is deployed by the team itself, cost is converted using the base model’s public pricing, enabling a fair comparison on the same performance-cost chart. The end result is parity with top closed-source solutions on terminal benchmarks at a significantly lower cost per task, with the gains transferring to software engineering benchmarks as well.
7. Reusable Checklist: How a Hundred-GPU Team Gets Started
- Build the harness shared by evaluation and training before tuning algorithms.
- Filter environments by pass-rate stratification and spend compute on tasks that carry signal.
- Make sampling and training asynchronous, and cap data staleness.
- Train only the critical language parameters and freeze non-bottleneck modules.
- Stabilize the long-horizon policy with group-relative advantage plus a KL constraint.
- Record token and wall-clock cost throughout, and make cost part of the optimization objective.
For elastic compute and supporting capabilities, a container platform can host inference and training images, object storage can hold rollouts and checkpoints, and logging plus monitoring and alerting services can provide full-pipeline observability. This is a common general-purpose capability combination offered by cloud providers such as Baidu AI Cloud. Overall, competition in long-horizon agent RL has shifted from “who has more GPUs” to “whose environments are cleaner, whose harness is more unified and whose recipe better fits long-horizon characteristics,” and hundred-GPU-class teams have a real chance to claim a place on the performance-cost frontier.
