Building a 300B Agent in 5 Days: How Full-Parameter RL Cut Per-Task Cost by 30x

    This article examines how a research team trained a 300B-scale terminal and coding agent using full-parameter reinforcement learning on 64 accelerators in under five days, reaching roughly 46% Pass@1 on mainstream terminal benchmarks while reducing per-task cost to about 1/30 under a high-inference-intensity comparison. It breaks down the four-stage pipeline from base model evaluation to verifiable environments and stable RL design, then details inference-side cost controls, the cloud infrastructure categories that support such a platform, and a reusable practice checklist for engineering teams.

    1. The Cost Cliff Behind Agent Capabilities

    Over the past year, agents have improved rapidly at terminal operation and software engineering tasks. That progress, however, has often come with a matching rise in training and inference costs. Three pain points are widely observed across the industry:

    1. High training cost: Full-parameter reinforcement learning requires the policy model, reference model, value/reward model, and optimizer states to be resident at the same time, putting far more pressure on memory and bandwidth than supervised fine-tuning.
    2. High environment cost: Terminal and coding tasks need real executable environments (containers, dependencies, test frameworks), and environment preparation and snapshot management often become the throughput bottleneck.
    3. High inference cost: High inference intensity (long chains of thought, multiple rounds of reflection, repeated sampling and voting) improves accuracy, but the cost per task can rise by an order of magnitude.

    Recently, a research team released a 300B-scale terminal and coding agent. Using only 64 accelerators and less than five days, they completed full-parameter reinforcement learning training and reached about 46% Pass@1 on mainstream terminal benchmarks, on par with leading closed-source solutions, while the cost per task was as low as roughly 1/30 under a high-inference-intensity comparison. The value of this result is not any single number. It validates an engineering path: by jointly designing efficiency optimizations on the training side and cost constraints on the inference side, it is possible to approach state-of-the-art results with limited compute.

    2. Technical Breakdown: A Four-Stage Pipeline from Base Model to Agent

    2.1 Base Model Selection and Capability Boundary Check

    The first step in engineering practice is not training but a “health check.” Run a capability boundary evaluation on candidate base models to establish baseline scores on dimensions such as code completion, command-line understanding, long-context localization, and tool-call format compliance. This avoids mistaking a base model defect for a reinforcement learning failure.

    2.2 Building a Verifiable Environment

    Reinforcement learning depends on reliable reward signals. Terminal and coding tasks have a natural advantage here: rewards are verifiable. Unit test pass or fail, command exit codes, and file state differences can all be judged automatically. Key construction points include:

    • Layered environment images: a base dependency layer, a project dependency layer, and a task initial state layer, using the container platform’s image caching and layer reuse to reduce startup overhead;
    • Snapshots and rollback: every task starts from the same initial snapshot to guarantee reproducibility;
    • Sandbox isolation: restrict network and file system permissions to prevent side effects during training;
    • Logging and tracing: write execution traces to a logging service to make failure attribution easier.

    Illustrative environment invocation logic (pseudocode):

    1. def rollout(task, policy, max_steps=30):
    2. env = Sandbox.from_snapshot(task.snapshot_id) # Isolated environment
    3. traj = []
    4. for step in range(max_steps):
    5. action = policy.generate(env.observation, tools=env.tool_schema)
    6. result = env.execute(action) # Real execution, returns exit code/output
    7. traj.append((action, result))
    8. if result.done:
    9. break
    10. reward = env.verify() # Unit tests / state verification
    11. return traj, reward

    2.3 Stability Design for Full-Parameter Reinforcement Learning

    Full-parameter training means all weights participate in updates, which makes stability design especially critical:

    • Reference constraint: use a reference model and a divergence constraint to suppress policy drift and prevent output degradation caused by reward hacking;
    • Advantage estimation: use group-relative advantage (sampling multiple trajectories for the same task and normalizing within the group) instead of an additional value network, which significantly reduces memory usage and is one of the keys to feasibility at the 64-card scale;
    • Curriculum and difficulty tiers: bucket tasks by pass rate and prioritize sampling medium-difficulty tasks that are “learnable but not yet learned,” increasing the information value per sample;
    • Length and format penalties: apply light penalties for invalid tool calls and excessively long, unproductive reasoning, acting directly on downstream inference cost.

    2.4 Transfer Validation

    An improvement on a single benchmark is not enough to demonstrate capability. Transfer validation is needed across multiple software engineering benchmarks, including issue-level fixes, multi-file refactoring, and dependency conflict resolution, to observe whether the model is overfitting to a specific test framework.

    3. Inference-Side Cost Control: Breaking Down the 30x Gap

    The cost per task can be abstracted as:

    1. Cost per task ≈ average tokens × unit price × average samples + environment execution cost

    Actionable cost reduction measures:

    1. Adaptive inference budget: short chains for simple tasks, long chains for complex ones, using confidence or consistency across multiple samples to decide whether to add more reasoning;
    2. Early stopping and majority voting instead of large-scale voting: replace large-scale voting with the consistency of a small number of parallel samples;
    3. Context compression: use retrieval-based localization for long files instead of stuffing in the full content;
    4. Cache reuse: cache build artifacts for the same repository and the same dependencies on the container platform, which can noticeably reduce environment cost;
    5. Batching and elastic scaling: use the container platform’s elastic capabilities to scale out during training and evaluation peaks and release capacity during troughs.

    4. Infrastructure and Mapping to General Cloud Capabilities

    Under the constraint of 64 cards and five days, engineering efficiency determines success. General cloud product categories can provide the supporting capabilities:

    • Container platform: elastic scheduling for the sandbox environment pool and training jobs;
    • Object storage: storing environment images, trajectory data, and checkpoints;
    • Message queue: decoupling the three stages of trajectory generation, reward verification, and training updates to avoid long-tail tasks blocking the pipeline;
    • Logging service and monitoring/alerting: tracking reward curves, environment failure rates, and memory and throughput metrics, with automatic alerts on anomalies;
    • Data lake/data warehouse capabilities: clustering failure cases and analyzing curriculum sampling.

    The capability forms that Baidu AI Cloud provides across these general categories can serve as a practical reference for building such a training and evaluation platform, with specific configurations to be assessed against the actual task scale.

    5. A Reusable Practice Checklist

    • Run the base model health check first, then define the training plan;
    • Rewards must be automatically verifiable, and environments must support snapshot and rollback;
    • Use group-relative advantage instead of an independent value network to compress memory usage;
    • Factor inference length into the reward design so cost is constrained starting from the training phase;
    • Establish multi-benchmark transfer validation to prevent single-point overfitting;
    • Instrument the whole pipeline: monitor throughput, failure rate, and cost per task curves at the same time.

    6. Conclusion

    The significance of “64 cards, less than five days, an order-of-magnitude cost reduction” is that it pulls agent training back from “throwing compute at the problem” to “competing on engineering.” For development teams, the real moat is a verifiable environment, a stable reinforcement learning pipeline, and a fine-grained cost model, rather than parameter scale alone.