Cutting Costs on Long-Horizon Agent Reinforcement Learning at the ~100-GPU Scale: A Practical Recipe

    Long-horizon agents must execute multi-step tool use, environment interaction, and delayed-reward tasks, making RL training far more expensive than single-turn models. This article presents a cost-optimization recipe for training such agents on roughly one hundred GPUs with full-parameter reinforcement learning. It covers reliable environment and verifier design, an RL formulation that handles long, stale, low-precision trajectories, a unified execution framework shared across training, evaluation, and deployment, and the engineering practices—parallelism, async sampling, checkpointing, and full cost accounting—needed to approach the performance–cost Pareto frontier and reduce per-task cost by an order of magnitude without simply scaling up compute.

    1. Background: The Cost Bottleneck of Long-Horizon Agents

    The core difference between long-horizon agents and single-turn Q&A models is that agents must execute multi-step operations in real or semi-real environments: reading files, running commands, editing code, observing output, retrying on errors, and finally verifying results. A training sample is no longer a static piece of text but a trajectory containing tool calls, environment state changes, and delayed rewards. This introduces three challenges:

    1. Sparse and delayed rewards: A clear signal only appears when the task ultimately succeeds or fails; intermediate step quality is hard to label directly.
    2. Long trajectories and stale policies: With asynchronous sampling, the policy that generated a trajectory may lag behind the current training policy, creating off-policy bias.
    3. Complex cost structure: Total cost includes not just training compute but also inference tokens, tool calls, environment sandboxes, retries, and evaluation overhead.

    Therefore, the engineering goal should not merely be “maximizing first-pass success rate,” but moving toward the Pareto frontier on the performance–cost plane: higher pass rates at the same cost, or lower per-task cost at the same pass rate. A recently published training recipe suggests that a cluster of roughly one hundred GPUs—through careful environment filtering, an RL formulation designed for long trajectories, and a shared execution framework across training, evaluation, and deployment—can achieve pass rates on long-horizon terminal and coding tasks close to high-inference-budget frontier approaches, while reducing per-task cost by more than an order of magnitude. The key is not stacking more GPUs, but making every unit of compute and every sampled trajectory produce reliable training signal.

    2. Overall Approach: Full-Parameter RL with a Unified Execution Framework

    The overall method can be abstracted into four components:

    • Base model and update scope: Use a sparse-activation base model with roughly 300B total parameters and tens of billions of activated parameters per token, and perform full-parameter reinforcement learning that updates the language backbone. Freeze non-language modules such as the vision encoder to prevent low-quality signals from corrupting the multimodal components during long-horizon tasks.
    • Environment filtering: Select verifiable, moderately difficult, reliably signaled tasks from the task pool to form a dynamic curriculum.
    • RL formulation: For long, stale, low-precision trajectory sampling, design mechanisms for version windows, importance correction, length control, advantage normalization, and failure-trajectory utilization.
    • Unified execution framework: Training, evaluation, and inference optimization share the same tool protocol, sandbox specification, timeout/retry policy, and logging, reducing performance drift caused by train/eval environment mismatch.

    The core idea: a ~100-GPU cluster should not chase maximum scale, but maximize the effective sample rate. If a large fraction of trajectories provide no gradient signal—because of unstable environments, overly hard tasks, or unreliable verifiers—then adding compute only amplifies waste.

    3. Environment Filtering: Make Every Task Provide Reliable Signal

    Environment filtering is the first lever in long-horizon agent RL. A very hard task with a reliable, attributable failure mode is still valuable; conversely, a task with moderate pass rates but a hackable reward will poison training.

    3.1 Verifiability and Verifier Design

    Terminal tasks should rely on file state, command output, exit codes, directory snapshots, and test results for verification; coding tasks should use test cases, static checks, build results, and diff comparison. Verifiers should satisfy:

    • Deterministic or semi-deterministic behavior: Repeated verification of the same trajectory should yield stable results.
    • Multi-signal fusion: Don’t look only at the final string; combine file diffs, number of passing tests, and key behaviors.
    • Hidden tests and randomization: Keep some test cases hidden to prevent the model from overfitting to public ones.
    • Failure classification: Distinguish “environment error,” “tool error,” “model error,” and “timeout,” so environment noise is not treated as a negative sample.

    3.2 Difficulty Stratification and Dynamic Curriculum

    Tasks with very low success rates provide almost no learnable signal; tasks with very high success rates have low marginal value. In practice, maintain a difficulty stratification, prioritize sampling tasks with mid-range success rates, and adjust dynamically as policy capability improves. The curriculum need not be strictly linear—it can be bucketed by task type, tool complexity, and trajectory length.

    3.3 Environment Snapshots and Isolation

    Each task should run in a containerized sandbox with filesystem snapshots, resource quotas, network restrictions, and timeout control. This ensures reproducibility and prevents agents from affecting other tasks through side effects. Training and evaluation environments should use the same image specification and tool permissions.

    3.4 Reward-Hacking Defense

    Long-horizon tasks are prone to “verifier bypass” behaviors, such as directly modifying test files, fabricating output, or exploiting leftover state. Countermeasures include hidden tests, randomized task parameters, cross-checking with multiple verifiers, trajectory auditing, and penalties for anomalous behavior.

    Illustrative filtering logic:

    1. def select_training_tasks(task_pool, policy_version):
    2. selected = []
    3. for task in task_pool:
    4. verifier = task.verifier
    5. if not verifier.is_reliable():
    6. continue
    7. stats = estimate_success_rate(task, policy_version)
    8. if stats.success_rate < 0.15 or stats.success_rate > 0.85:
    9. continue
    10. if task.has_reward_hack_risk() and not task.has_hidden_tests():
    11. continue
    12. selected.append(task)
    13. return curriculum_sort(selected)

    4. An RL Formulation for Long, Stale, Low-Precision Trajectories

    Trajectory sampling for long-horizon tasks is expensive. Fully synchronous sampling wastes compute severely; asynchronous sampling improves throughput but introduces policy staleness. Low-precision inference reduces cost but brings numerical noise and action-distribution shift. The formulation must handle both.

    4.1 Version Windows and Importance Correction

    Record the policy version that generated each trajectory. During training, only accept trajectories whose version falls within a window of the current policy; downweight or discard samples outside the window. Apply importance correction to in-window samples, but always clip it to avoid variance explosion.

    4.2 Length Control and Truncation Policy

    Longer trajectories are not always better. Set maximum steps, maximum tokens, and maximum tool calls, and penalize ineffective retries, repeated commands, and no-op actions. Keep length penalties mild, so the model doesn’t skip necessary verification just to be short.

    4.3 Grouped Sampling and Advantage Normalization

    Sample multiple trajectories per task to form within-group comparisons. Normalize advantage estimates within groups to reduce scale differences from task difficulty. Do not discard all failed trajectories: if the failure cause is attributable, use it as a negative sample; if it’s environment noise, filter it out.

    4.4 Stability Under Low-Precision Sampling

    Low-precision inference can significantly reduce sampling cost, but you must monitor action-distribution drift, tool-argument parsing failure rates, and changes in verification pass rates. Mitigate with sampling temperature adjustment, retry mechanisms, high-precision fallback for critical steps, and numerical stabilization.

    4.5 Supervised Fine-Tuning for Cold Start

    Before RL, run supervised fine-tuning on a small set of high-quality trajectories so the model learns tool-call formats, file-operation conventions, and verification habits—this markedly improves early sampling success rates. Cold-start data should cover both successful paths and common error-recovery paths.

    5. A Shared Execution Framework for Training, Evaluation, and Optimization

    A unified execution framework is key to avoiding inflated evaluation scores and training drift. The tool protocol, sandbox image, timeout/retry policy, permission control, and log format used in training should remain consistent across evaluation and inference optimization.

    The framework should include at least:

    • Unified task description: natural-language instruction, initial file state, available tools, verification method.
    • Unified tool protocol: stable input/output formats for command execution, file read/write, search, and patch application.
    • Unified sandbox specification: image versions, resource quotas, network policy, timeouts.
    • Unified logging: per-step tool calls, token consumption, latency, error codes, and verification results.
    • Unified cost accounting: training amortization, inference tokens, tool resources, and retry costs all go into the same ledger.

    Illustrative training loop:

    1. for iteration in range(max_iterations):
    2. tasks = select_training_tasks(task_pool, policy.version)
    3. trajectories = async_rollout(
    4. policy,
    5. tasks,
    6. precision="low",
    7. max_steps=MAX_STEPS,
    8. version_window=VERSION_WINDOW,
    9. )
    10. filtered = filter_by_staleness_and_noise(trajectories)
    11. advantages = group_normalize(filtered.rewards)
    12. policy.update(filtered, advantages, kl_coef=KL_COEF)
    13. policy.version += 1
    14. evaluate_on_fixed_suite(policy, shared_harness=True)

    6. Engineering Practices for ~100-GPU Full-Parameter Training

    Training a ~300B model on a ~100-GPU cluster requires coordination between engineering and algorithms:

    1. Parallelism strategy: Combine data, tensor, and pipeline parallelism; adjust the split according to memory and communication bottlenecks. For full-parameter updates, use gradient checkpointing, mixed precision, and communication overlap to reduce overhead.
    2. Decoupled sampling and training: Pipeline trajectory sampling and policy updates asynchronously; use experience queues and priority sampling so long-tail tasks don’t block overall throughput.
    3. Checkpointing and fault tolerance: Long-horizon training requires frequent checkpoints, resume-from-failure, and isolation of failing tasks so a single environment fault doesn’t take down the whole run.
    4. Unified cost accounting: For self-deployment, don’t count only accelerator card-hours—estimate inference token cost at equivalent public pricing, and include tool sandboxes and retries in per-task cost.
    5. Small-scale ablations: Validate environment filtering, version windows, length penalties, and low-precision strategies on a small task set before scaling to a hundred GPUs, to avoid large-scale trial and error.

    7. Evaluation and the Performance–Cost Pareto Frontier

    Evaluation should report first-pass success rate, mean over multiple trials, average per-task cost, and cost distribution. Reporting only pass rates hides cost differences; reporting only cost hides long-tail failures.

    Recommended evaluation protocol:

    • Fix the execution framework, tool permissions, timeouts, and retry counts;
    • Average over multiple trials and report confidence intervals;
    • Treat inference budget as a variable and compare pass-rate/cost curves across budgets;
    • Validate transfer on both terminal tasks and software-engineering tasks;
    • Include training amortization, inference tokens, tool calls, and failure retries in cost.

    Only when a recipe achieves comparable pass rates at lower cost across multiple benchmarks can you claim it is near the Pareto frontier, rather than overfitting to a single benchmark.

    8. Practical Checklist

    1. Build verifiable environments before scaling RL.
    2. Stratify task difficulty; prioritize mid-range success rates.
    3. Use version windows to control trajectory staleness; always clip importance correction.
    4. Pair low-precision sampling with monitoring and high-precision fallback for critical steps.
    5. Share the execution framework and log format across training, evaluation, and deployment.
    6. Account for tokens, tools, retries, and training amortization in cost.
    7. Defend against reward hacking: hidden tests, randomization, multiple verifiers, trajectory audits.
    8. Run small-scale ablations before scaling to a hundred GPUs.
    9. Track both pass rate and per-task cost; pursue Pareto improvements.
    10. Document environment versions, task-set versions, and training configs for reproducibility.

    9. Risks and Boundaries

    Long-horizon agent RL still has limits: benchmarks may saturate, environments may drift, verifiers may be bypassed, and cost estimates may be distorted by inconsistent accounting. Engineering teams should retain red-team testing, trajectory auditing, and sandbox permission control to prevent models from performing dangerous operations in real environments. A ~100-GPU cluster lowers the barrier to experimentation but cannot substitute for sustained investment in task quality, verification reliability, and cost-accounting discipline.

    In summary, optimizing performance and cost for long-horizon agents is a systems problem: environment filtering determines signal quality, the RL formulation determines sample efficiency, the unified execution framework determines evaluation credibility, and training engineering determines compute utilization. Only when all four work together can you reliably approach the performance–cost Pareto frontier under limited compute.