Long-Horizon Agent RL: An Open Recipe for Low-Cost, High-Performance Training
An open reinforcement learning recipe shows how a 300B-class base model can become a capable terminal and coding agent using 64 high-memory accelerators in under five days. This article examines the reported results and the reusable engineering principles behind them: full-parameter RL, verifier-based rewards, curriculum sampling, failure early stopping, cost tracking, and held-out evaluation. It also outlines how to build a reproducible training pipeline while interpreting performance and cost comparisons carefully.
Long-horizon agents are moving beyond fixing a single bug toward hours of continuous terminal operations and programming. Reinforcement learning costs are rising with them. A training sample is no longer necessarily a short question and answer; it may be a complete trajectory spanning hours and hundreds of tool calls. A failure anywhere along the way can waste hours of GPU time.
Frontier teams can scale reinforcement learning across thousands of accelerators. Most teams face a more practical question: how can they achieve useful long-horizon agent performance with limited compute while keeping per-task costs acceptable?
A publicly described open training recipe offers a useful case study. Starting from a 300B-class base model, it uses full-parameter reinforcement learning to train a terminal and coding agent. The reported results include:
- 46.2% Pass@1 on a terminal-task benchmark, comparable to frontier models in the same performance tier.
- More than 30-fold lower per-task cost than comparable frontier models running at their highest reasoning-effort settings.
- Training on 64 high-memory accelerators in under five days.
- Improvements that also transferred to two software engineering evaluation sets.
Rather than focusing on a specific product, this article examines the reusable methodology behind the recipe: controlling long-horizon RL costs, designing meaningful evaluations, and building a reproducible training pipeline.
1. Why Long-Horizon Agent RL Is So Expensive
Reinforcement learning for long-horizon agents differs fundamentally from training on single-turn tasks. In a traditional task, the model produces a text response and receives a reward. In a long-horizon task, it repeatedly executes commands, reads and writes files, calls tools, observes feedback, and revises its strategy until the task succeeds or fails.
The training sample therefore becomes a trajectory: a sequence of states, actions, tool responses, intermediate results, and final verification.
This amplifies costs in three ways.
Expensive rollouts
Each trajectory requires interaction with a real or simulated environment and may take hours to complete. With parallel sampling, compute consumption grows with trajectory length and the number of tool-call rounds.
Expensive failures
An incorrect command early in a task can invalidate everything that follows. If the training system cannot detect failure and stop promptly, substantial GPU time may be spent on trajectories that have no realistic path to success.
Difficult reward design
Final outcomes are often sparse and delayed, while intermediate steps are difficult to label directly. Rewards that are too coarse reduce learning efficiency. Rewards that are too dense can introduce unintended preferences.
Long-horizon agent RL is therefore not just an algorithmic problem. It is also a systems engineering and cost-management problem.
A simplified cost model illustrates the main components:
Training cost per task ≈ Average trajectory duration× Number of parallel accelerators× Unit compute cost+ Failed-attempt retry costs+ Environment and tool-call overhead+ Evaluation and verification overhead
This points to several optimization priorities: shorten unproductive trajectories, improve rollout success rates, reuse environments and caches, use verifiers to trigger early stopping, increase task difficulty through curriculum learning, and incorporate evaluation into the training loop.
2. From a Base Model to an Open Training Recipe
The central contribution is not an isolated model capability, but a complete path from a base model to a trained agent. The starting point is a 300B-class model, and the training method is full-parameter reinforcement learning.
Full-parameter RL updates the model’s parameters as a whole rather than training only a small set of adapter layers. For long-horizon agents, the potential advantage is greater policy capacity for multi-turn tool use, long-context state tracking, and complex action sequences. The trade-off is higher demand for memory, communication bandwidth, and training stability.
The value of an open recipe is that it demonstrates how task organization, sampling, and training workflow can make full-parameter RL practical on a moderately sized cluster while achieving a useful performance–cost trade-off.
The relevant concept is the Pareto frontier: a configuration is Pareto-efficient when no alternative can improve performance without increasing cost, or reduce cost without sacrificing performance. The reported terminal benchmark results suggest that the recipe aims to balance these objectives rather than reduce cost at the expense of capability.
Based on the public description, its training objective can be summarized as maximizing task success under a given compute budget and task distribution while constraining average per-task cost.
That requires a closed loop:
Task sampling → trajectory generation → outcome verification → policy update → evaluation and regression checks
Offline fine-tuning alone does not provide this loop.
3. Key Design Choices: Full-Parameter RL and Task-Level Cost Control
A long-horizon agent RL training loop can be expressed with the following pseudocode:
for iteration in range(max_iterations):tasks = sample_tasks_by_curriculum(task_pool, difficulty)trajectories = parallel_rollout(policy, tasks, max_turns=task_budget)rewards = verify_outcomes(trajectories, validators)advantages = compute_advantages(rewards, group_baseline)update_policy(policy, trajectories, advantages)if iteration % eval_interval == 0:metrics = evaluate(policy, heldout_tasks)checkpoint_if_improved(metrics)log_cost_per_task(trajectories)
This is a conceptual workflow, not a specification of a particular API or an exact implementation. It highlights five important design choices.
Curriculum-based sampling
Long-horizon tasks vary widely in difficulty. Giving an early-stage policy only the most complex tasks can produce extremely high failure rates.
Sampling by difficulty allows the policy to learn shorter, verifiable tasks first, then progress toward longer sequences of tool interactions.
Parallel rollouts
Long trajectories require parallel sampling to maintain throughput. More parallelism, however, is not always better.
Concurrency must match available memory, environment capacity, and tool-call quotas. Excessive parallelism can create queues and retries that increase costs rather than reduce them.
Verifier-based rewards
Terminal and programming tasks often have objectively checkable outcomes: whether a command succeeds, tests pass, or files reach the required state.
Verifiers can produce final rewards more scalably than manual labeling. Intermediate controls can support this process through format constraints, tool-call validity checks, and early-stop signals.
Cost logging
The training system should record each trajectory’s number of turns, elapsed time, tool-call count, failure stage, and GPU utilization.
Making these measurements part of the training feedback enables optimization for per-task cost, not merely overall throughput.
Early stopping for failed trajectories
Trajectories that clearly cannot complete the task should be stopped promptly. Common mechanisms include:
- Detecting repeated ineffective commands.
- Enforcing timeouts.
- Detecting environment errors.
- Using verifiers to identify failure early.
The purpose is not to reduce training quality, but to redirect compute away from unproductive samples.
At the infrastructure level, a general-purpose container platform can isolate task environments, object storage can hold trajectories and checkpoints, and logging and monitoring services can track training stability. Where applicable, Baidu AI Cloud can provide these general categories of infrastructure; the approach does not depend on a specific interface.
The essential design principle is to decouple environment lifecycle management, trajectory storage, and training scheduling. Otherwise, unstable environments can force expensive long-running tasks to restart repeatedly.
4. Training and Evaluation: Balancing Performance and Cost
The publicly reported training run used 64 high-memory accelerators for less than five days.
This is not a claim that the absolute compute requirement is small. Its significance is that it places long-horizon agent RL within a scale that moderately resourced teams can consider, rather than treating it as the exclusive domain of very large clusters.
Running efficiently at this scale typically requires several engineering practices:
- Mixed-precision training.
- Gradient checkpointing.
- Parameter sharding.
- Overlapping asynchronous rollouts with training.
- Fast checkpoint recovery.
- Parallel evaluation tasks.
These are general best practices, not confirmed details of a particular implementation or capabilities unique to one product.
Interpreting Pass@1
The reported 46.2% Pass@1 on a terminal-task benchmark indicates substantial first-attempt capability in terminal operations and programming.
Pass@1 measures the proportion of tasks completed successfully with one sampled attempt per task. It is stricter than selecting the best result from multiple attempts and more closely reflects the cost of a single-attempt deployment.
A model that requires many retries can incur substantially higher per-task costs. Pass@1 and cost should therefore be evaluated together.
Interpreting the cost comparison
The recipe reportedly achieved performance comparable to frontier models in the same tier while costing more than 30 times less per task than those models at their highest reasoning-effort settings.
The important point is the performance–cost trade-off, not low cost in isolation. At a similar performance level, reducing inference and retry expenses can materially improve deployment economics.
For long-horizon agents, costs extend beyond model inference. Tool calls, environment waits, and failed-attempt retries also contribute. A policy with a higher first-attempt success rate can reduce both inference costs and environment overhead.
Transfer to software engineering tasks
The reported improvements also transferred to two software engineering evaluation sets. This suggests that the benefits were not limited to one terminal benchmark and that training improved reusable behaviors such as reading code, editing code, running tests, and fixing failures.
For developers, this matters beyond a single benchmark score. Real engineering tasks rarely match the training distribution exactly. Transfer results provide evidence of some generalization, although they do not establish that benchmark-specific overfitting has been eliminated.
5. How to Build a Reproducible, Cost-Aware Long-Horizon RL Pipeline
Teams adopting this approach can proceed through seven practical steps.
Step 1: Define task boundaries and verifiers
Start with tasks that have objective success signals, such as successful command execution, required file changes, passing tests, or successful builds.
Without reliable verifiers, long-horizon RL can become a process of generating plausible-looking behavior that cannot be evaluated consistently.
Step 2: Establish a trajectory data model
Each trajectory should record at least:
- Task identifier.
- Initial state.
- Action sequence.
- Tool responses.
- Intermediate verification results.
- Final reward.
- Elapsed time.
- Cost.
Trajectory storage should support retrieval by task, difficulty, and failure stage so that failures can be analyzed systematically.
Step 3: Design the curriculum and sampling mix
Sample more short-horizon tasks early, then gradually increase the share of multi-turn tasks.
Do not simply discard tasks with high failure rates. Identify where they fail: environment setup, tool-call formatting, or policy decisions. These failure categories require different fixes.
Step 4: Put cost metrics on the training dashboard
Track more than loss and success rate. Useful operational metrics include:
- Average turns per task.
- Average task duration.
- Failure-triggered early-stop rate.
- Environment retry rate.
- Output per GPU-hour.
Cost optimization becomes actionable only when costs are visible.
Step 5: Separate evaluation from training
Keep held-out tasks and evaluate Pass@1 and per-task cost regularly.
Avoid reporting only the best results, and do not use tasks encountered during training as evidence of generalization.
Step 6: Make checkpointing and recovery reliable
Long-running training is exposed to environment and hardware failures. Checkpoints should include model parameters, optimizer state, sampling progress, and curriculum state.
Recovery should resume training from a consistent state rather than require a complete restart.
Step 7: Control reasoning effort at deployment
The highest reasoning-effort settings often carry higher costs. In practice, reasoning budgets should reflect task difficulty: allow simple tasks to finish quickly, while giving complex tasks more sampling or reasoning steps when needed.
The performance–cost frontier is not a single fixed configuration. It can be managed through adjustable execution budgets.
6. Limitations and Outlook
An open recipe does not mean that every team can reproduce the results by copying the workflow unchanged.
Long-horizon agent RL remains sensitive to task distribution, environment stability, verifier quality, and engineering execution. The reported result—64 accelerators and less than five days—was achieved with a particular task set, base model, and training process. Changing the tasks, environment, or model scale changes the cost profile.
The transferable lessons are methodological:
- Put verifiers at the center of the workflow.
- Treat cost as an explicit constraint.
- Use curriculum sampling and failure early stopping to improve sample efficiency.
- Test generalization through transfer evaluations.
The broader signal is that long-horizon agent RL need not rely exclusively on massive clusters. Open recipes and disciplined systems engineering can help moderately sized compute deployments approach a competitive performance–cost frontier.
For developers and enterprises, the most reusable asset is not a particular model name. It is an observable, verifiable, and iterative training pipeline. Clear task definitions, reliable verifiers, and a cost-aware feedback loop are what move long-horizon agents from demonstrations toward production.
