Long-Horizon Agent RL: A Practical Guide to Cutting Training Costs
This article explains why long-horizon agents are expensive on the training side and how a publicly shared engineering recipe reduced both cost and training budget without sacrificing quality. It breaks down the cost structure of a single task, outlines a reusable full-parameter RL workflow with verifiable rewards and trajectory-level early stopping, and covers evaluation practices for reproducible results. You will learn how to select models using a performance-per-cost Pareto frontier and how smaller teams can adapt the approach at a reduced scale.
1. Why Long-Horizon Agents Are Expensive on the Training Side
Long-horizon agents are pushing task boundaries from “fix a bug” to hours of continuous terminal operations and software engineering work. As tasks get longer, the sampling cost of reinforcement learning (RL) grows sharply: a single training sample often corresponds to one complete attempt that lasts hours and involves hundreds of tool calls. If any step in the middle fails, you lose hours of compute time, not the millisecond-level cost of a single forward pass.
This creates a typical asymmetry. Inference costs can be billed per task, cached, or downgraded. Training costs, however, are tied to an entire trajectory that cannot be split. A common industry response is to scale up the cluster for more throughput, but most teams do not have the conditions to run large-scale RL across thousands of accelerators. The more valuable question is therefore not “can we throw more hardware at it,” but: can we complete long-horizon RL training reliably and reproducibly with limited compute?
2. Core Finding: Pushing Performance and Cost onto the Same Frontier
A recent public engineering blog offers a useful reference point: starting from a general-purpose base model at the 300B scale, full-parameter reinforcement learning produced an agent variant for terminal and coding scenarios. The key results can be summarized in three points:
- Performance on par with the top tier: on terminal benchmarks, the single-attempt pass rate (Pass@1) reached roughly 46%, in the same range as the strongest general models at maximum reasoning effort.
- A significant cost reduction: on the same tasks, the cost per task was more than an order of magnitude lower than the maximum-reasoning-effort option (the original reports more than 30x).
- A controlled training budget: the entire run used 64 next-generation accelerators, took less than 5 days, and came with a published training recipe.
More importantly, the gains were not limited to a single benchmark; they transferred to multiple software engineering evaluation sets. This suggests the benefit comes from long-horizon execution ability itself rather than overfitting to one test set.
Engineering takeaway: if you are selecting a model for long-horizon agents, the evaluation dimension should expand from “benchmark score” to a two-dimensional view of “score / cost per task,” looking for a Pareto frontier on the performance-cost plane instead of a single optimum.
3. Breaking Down the Cost Structure
Before you can reduce cost, you need to see where it goes. A complete long-horizon agent task typically includes:
- Multiple rounds of tool calls: reading files, executing commands, running tests, and checking logs, with the context reconstructed at every turn;
- Long-context maintenance: the history keeps accumulating, and attention overhead rises with length;
- Failure retries: unstable environments, command timeouts, and missing dependencies can invalidate an entire trajectory;
- Evaluation overhead: Pass@1 usually requires multiple independent trials averaged together, and evaluation is itself a substantial inference cost.
Together, these four costs make “cost per task” a metric closer to the real experience than “price per million tokens.” A practical first step is to build an internal cost ledger:
cost per task ≈ (average turns × input/output tokens per turn × unit price)+ retry factor × base cost+ number of evaluation repeats × cost per evaluation
The retry factor is often underestimated. Making the environment stable, setting timeout policies, and pre-installing dependencies is equivalent to giving training and evaluation a direct discount.
4. Method: A Reusable Long-Horizon RL Recipe
Following the ideas in the public recipe, you can abstract the following engineering skeleton (illustrative, not a specific product interface):
- Base model choice: prefer a mid-sized base with strong general ability and controllable inference cost rather than the largest model available. Long-horizon tasks depend more on stability than on peak single-step intelligence.
- Full-parameter reinforcement learning: compared with tuning only a small number of parameters, full-parameter updates help the model form a consistent behavioral policy over long trajectories and reduce cases where “local steps look right but the overall run drifts.”
- Task and reward design: the reward should reflect whether the task is actually complete, not whether the steps look plausible. For terminal tasks, verifiable test passes, command return codes, and file state changes are relatively reliable signals.
- Trajectory-level sampling and filtering: apply segmented checks to very long trajectories and discard clearly off-track samples early, so hours of compute are not spent on wrong demonstrations.
- Evaluation isolation: keep the training harness separate from the external evaluation harness to avoid inconsistent metric definitions; average over multiple trials to reduce misjudgments caused by variance.
Illustrative pseudocode:
for batch in task_pool:traj = rollout(policy, env, max_turns=100)if not env.is_consistent(traj):continue # early stop to save long-trajectory computereward = verify(traj) # rely on verifiable resultsloss = ppo_loss(policy, traj, reward)update(policy, loss) # full-parameter update
5. Evaluation and Reproducibility: Making the Conclusions Hold
Evaluation is where teams most easily end up talking to themselves. Reliable practices include:
- Consistent definitions: specify the number of trials, temperature, maximum turns, and timeout used for Pass@1;
- Cross-validation across benchmarks: beyond terminal benchmarks, add software engineering benchmarks to see whether the capability transfers;
- Presenting cost in the same chart: plot pass rate and cost per task on the same figure (logarithmic axes are more intuitive) and judge quality by the Pareto frontier;
- Publishing the recipe: release the data mix, reward design, hyperparameters, and compute budget together so others can reproduce the work.
6. Practical Advice: How Ordinary Teams Can Adapt
Even without 64 next-generation accelerators, you can adopt the approach by “shrinking the scale while keeping the structure”:
- Start with a small model to verify that the reward and data pipeline are reliable;
- Engineer environment stability (container platforms, pre-built images, log services, monitoring and alerting) to cut wasted retries;
- Use object storage and message queues to manage trajectory data and task scheduling so long tasks do not block others;
- Iterate with cost per task as the core metric rather than looking only at benchmark scores;
- In a cloud environment with general capabilities such as container platforms, log services, monitoring and alerting, and object storage, such as Baidu AI Cloud, it is easier to build a reproducible training and evaluation pipeline.
7. Conclusion
Competition among long-horizon agents is shifting from “whose model is bigger” to “whose cost per task is lower and whose recipe is more reproducible.” Training an agent in under 5 days on 64 accelerators that matches the top tier in quality at an order of magnitude lower cost is fundamentally a win in engineering efficiency: it turns long-horizon RL from a luxury for a few labs into an engineering problem most teams can discuss. For developers, the most valuable takeaways are not any single number but three things: align objectives with verifiable rewards, control cost with trajectory-level early stopping, and make selection decisions with a Pareto frontier.
