Training Long-Horizon AI Agents with RL: Approaching the Performance-Cost Pareto Frontier on a Small Compute Budget

    Long-horizon agents that run for hours and make hundreds of tool calls deliver enormous value in terminal operations and software engineering, but reinforcement learning (RL) training for them has been prohibitively expensive for most teams. This article examines why long-horizon agent RL is so sample-inefficient, walks through a recently published small-compute training recipe that reached frontier-level performance with just 64 GPUs in under five days, and breaks down the key technical design points: base model selection, reward design, environment construction, training efficiency, and cost-aware evaluation. It closes with practical guidance for small and mid-sized teams looking to train long-horizon agents on a limited budget.

    Training Long-Horizon Agents with RL: Approaching the Performance-Cost Pareto Frontier on a Small Compute Budget

    1. The Cost Dilemma of Long-Horizon Agent Training

    Large language model agents are evolving from short-horizon tasks like “fix a bug” into long-horizon work that runs for hours and spans hundreds of tool calls. These long-horizon agents are extremely valuable in terminal operations and software engineering, but the cost of their RL training remains a barrier most small and mid-sized teams cannot cross.

    The core problem is extremely low sample efficiency:

    1. Single trajectories are extremely long: One training sample often corresponds to a complete task attempt lasting several hours and involving hundreds of tool calls.
    2. Errors are expensive: If any step in a trajectory goes wrong, the reward signal for the entire sample is compromised—and hours of GPU time are wasted.
    3. The scale bar is high: Frontier labs can brute-force RL training across thousands of GPUs; most teams have no such resources.

    What the industry actually needs, then, is not “more scale” but a smarter training recipe—one that approaches the performance-cost Pareto frontier with limited compute.

    2. Key Results from a Small-Compute RL Practice

    A recently published study demonstrated a different path: starting from a mid-sized open-source base model, the researchers produced a 300B-parameter terminal and coding agent through full-parameter RL training, and released the complete training recipe. Key figures include:

    • Training resources: Only 64 high-end GPUs, with training completed in under five days;
    • Terminal benchmark performance: A Pass@1 of 46.2% on a mainstream terminal capability benchmark, on par with several frontier closed-source models;
    • Cost advantage: The per-task cost is more than 30x lower than comparable models with high inference intensity;
    • Capability transfer: The performance gains also carried over to two mainstream software engineering benchmarks, indicating a general improvement in agent capability rather than overfitting to a single benchmark.

    The significance of these numbers is clear: the barrier to agent RL is shifting from a resource problem to a methods problem. Below, we break down the key design decisions behind this kind of training recipe from a technical perspective.

    3. Core Techniques for Long-Horizon Agent RL

    3.1 Base Model Selection: Start from a Mid-Sized Model, Not from Scratch

    This practice starts RL from a model that already has basic tool-calling and coding abilities. The logic behind this choice:

    • Pretraining has already solved language understanding and code knowledge;
    • The RL phase only needs to focus on the incremental capability of “long-horizon decision-making and error correction”;
    • The stronger the starting point, the fewer samples RL needs to converge, and the lower the training cost.

    For resource-constrained teams, this is an important lesson: prioritize open-source base models with foundational agent capabilities, and concentrate your compute on the RL phase.

    3.2 Reward Design: Handling Sparse Rewards on Long Trajectories

    Long-horizon tasks suffer from inherently sparse rewards—success can only be confirmed when the task is fully completed. Common mitigation strategies include:

    1. reward = completion reward (whether the task passes the tests)
    2. + process reward (optional, e.g., intermediate milestones)
    3. - penalty terms (ineffective loops, format violations, etc.)

    Note that while process rewards alleviate sparsity, they can also introduce reward hacking. The safe approach in practice is to rely primarily on verifiable final-outcome rewards—for example, objective signals such as test case pass rates or environment state checks—rather than subjective scores that are easy to game.

    3.3 Sample Construction: Diversity of Environments and Task Distributions

    The ceiling of RL training effectiveness largely depends on the quality of the training environments. A sensible task pool should satisfy:

    1. Tiered difficulty: From simple command operations to complex multi-file refactoring, covering multiple capability levels;
    2. Verifiability: Every task ships with automated verification scripts, so reward signals can be judged mechanically;
    3. Environment isolation: Agent-generated commands run inside containerized sandboxes to keep the training cluster safe;
    4. Analyzable failures: Full trajectories and tool-call logs are recorded to make failure attribution possible.

    3.4 Training Efficiency: Making Every GPU Count

    Small-compute training demands solid engineering optimizations:

    • Decouple asynchronous rollout from training: Agent-environment interaction is slow; pipeline sampling and gradient updates so GPUs never sit idle;
    • Trajectory truncation and checkpoint reuse: Apply sensible context window strategies to very long trajectories to reduce memory pressure;
    • Stability controls for full-parameter RL: Set reasonable KL constraints to prevent policy drift, combined with gradient clipping and batch normalization to keep training stable;
    • Fast recovery of failed runs: Terminate early when a trajectory is unrecoverable (e.g., a broken environment) and release the resources.

    3.5 Evaluation: Measure Cost and Performance Together

    The study notably emphasizes plotting Pass@1 against average per-task cost on a log scale to draw the Pareto frontier. This has direct lessons for engineering teams:

    • Comparing accuracy alone hides differences in inference overhead (high inference intensity usually means multi-round search and higher token consumption);
    • Comparing cost alone hides capability gaps;
    • Only a joint performance-cost view reflects an agent’s practical value.

    In addition, cross-validation across multiple benchmarks (terminal operations plus several software engineering benchmarks) is essential to confirm capability transfer and avoid the illusion of overfitting to a single benchmark.

    4. Practical Takeaways for Small and Mid-Sized Teams

    Drawing on the analysis above, teams training long-horizon agents on a limited budget can follow this path:

    1. Clarify your capability goal: Decide whether you are improving terminal operations, code fixing, or general planning, and choose your base model and task distribution accordingly;
    2. Build environments before training: High-quality, verifiable, isolated task environments are the prerequisite for successful RL—and their importance is often underestimated;
    3. Validate the recipe at small scale: First verify reward design and training stability with a small task set and fewer steps, then gradually expand the task pool;
    4. Establish cost accounting: Bring inference intensity, token consumption, and task success rate into a unified evaluation framework, and use the Pareto frontier to guide iteration;
    5. Invest in engineering infrastructure: Container sandboxes, log collection, monitoring and alerting, and trajectory replay directly determine training throughput and debuggability. In cloud environments, these capabilities are typically built on general-purpose cloud offerings such as container platforms, logging services, and monitoring/alerting products.

    5. Closing Thoughts

    The result—“64 GPUs, under five days, frontier-level performance, 30x lower cost”—shows that long-horizon agent RL is becoming democratized. The real competitive focus is no longer compute scale but how finely you tune the training recipe: base model selection, reward design, environment quality, training efficiency, and evaluation methodology all interlock. For teams hoping to get into agent training, rather than waiting for more compute, it is more effective to shore up each of these methodological pieces first—that is the viable path toward the Pareto frontier.