Training a Terminal Agent with 64 Accelerators in 5 Days

    This article explains how to train a terminal and coding agent under a limited compute budget by centering the training loop on verifiable tasks. It covers why terminal environments are hard to set up and why feedback is sparse and costly, how full-parameter reinforcement learning improves capability transfer and sample efficiency, and the engineering requirements it imposes on memory, parallelism, sampling, and observability. It also breaks down per-task cost into optimizable components, proposes a three-layer evaluation approach, and ends with a reproducible recipe checklist teams can follow directly.

    1. Background: Why Terminal and Coding Agents Are Expensive and Hard to Train

    Over the past two years, agents have moved from “being able to chat” to “being able to get work done.” Terminal operation and software engineering tasks are the scenarios that best demonstrate real productivity: the model has to read code, modify files, run commands, inspect errors, and iterate. This class of capability has two inherent difficulties.

    The first is strong environment dependencies. Unlike pure text question answering, terminal tasks must run on a real or simulated file system, process, and dependency environment. Both training and evaluation therefore require environment orchestration that is resettable, reproducible, and concurrent.

    The second is sparse and expensive feedback. Whether a task succeeds is often only known once the tests pass. There are many intermediate steps and many possible failure causes, so relying on manual annotation or large-scale trial-and-error sampling makes costs spiral quickly.

    As a result, the industry’s recent focus has shifted from “piling on more compute” to cost per task: within a limited number of accelerators and a limited time window, can smarter data, rewards, and training strategies push an agent’s pass rate into a usable range?

    2. Core Idea: A Training Paradigm Centered on Verifiable Tasks

    A repeatedly validated general practice is to define the training objective as an automatically判定able task success rate rather than a vague preference score. Terminal and coding scenarios are naturally suited to this, because success can be verified by objective signals such as tests, compilation, command exit codes, and file state.

    Verifiable tasks typically have three elements:

    • Initial state: a resettable working directory and runtime environment;
    • Action space: the agent is allowed to run controlled commands, read and write files, and invoke scripts;
    • Verification function: automated tests or rule checks that output a 0/1 result or a graded score.

    Illustrative pseudocode (unrelated to any specific product):

    1. def rollout(task, policy, max_steps=30):
    2. env = reset_env(task.snapshot)
    3. for t in range(max_steps):
    4. action = policy.observe(env.observation())
    5. env.apply(action) # controlled execution: whitelisted commands / sandbox
    6. if env.done():
    7. break
    8. return env.verify() # verifiable reward: test pass rate / rule checks

    When the reward is verifiable, reinforcement learning no longer depends on large-scale human preference annotation. The training loop is easier to automate and easier to advance steadily under a smaller compute budget.

    3. Key Engineering: Why Full-Parameter Reinforcement Learning Is More Efficient

    “Full-parameter reinforcement learning” means updating all of the model’s parameters throughout training, rather than training only a small set of adapter layers. It usually delivers two kinds of gains:

    1. More thorough capability transfer: the long-chain decision making, tool invocation, and error recovery required by terminal tasks often involve the model’s underlying representations, and full-parameter updates are more conducive to forming a stable policy.
    2. Higher sample efficiency: under verifiable rewards, full-parameter updates make fuller use of the success and failure signals in each trajectory, reducing the waste of “changing the shell without changing the core.”

    Full-parameter training, however, places higher demands on engineering and requires careful handling of three things:

    • Memory and parallelism: parameters, optimizer states, and activations all need to be partitioned sensibly; common approaches combine tensor, pipeline, and data parallelism, along with activation recomputation.
    • Decoupling sampling from training: deploy inference sampling and gradient updates separately so they do not compete for resources, improving overall throughput.
    • Observability: build monitoring, alerting, and logging for reward distributions, trajectory lengths, failure types, throughput, and queueing latency, so the root cause of “training that fails to improve” can be located quickly.

    4. Cost Control: Breaking “Cost per Task” into Optimizable Items

    Cost per task can be abstracted as:

    1. cost per task ≈ (sampling steps × inference cost per step + environment execution cost + retry cost) / successful tasks

    Common optimization directions include:

    • Shorter trajectories: reduce ineffective context growth through prompt structure, compressed tool returns, and history summarization.
    • Higher first-attempt pass rate: use verifiable rewards for curriculum learning, easy tasks first and hard tasks later, to lower the share of high-cost long-tail tasks.
    • Cheaper environment orchestration: layered caching of environment images, concurrency isolation, and fast rollback on failure reduce losses from being “stuck on the environment” rather than “stuck on the model.”
    • Tiered inference intensity: use low intensity for exploration and screening, and reserve high intensity for difficult samples or final review, avoiding the cost amplification of “maximum intensity everywhere.”

    For enterprise adoption, these capabilities can be mapped onto general cloud components: a container platform hosts resettable sandboxes, object storage holds task snapshots and artifacts, a message queue distributes tasks, and logging and monitoring track every decision and resource consumption.

    5. Evaluation and Transfer: Don’t Look at a Single Leaderboard

    Whether a terminal agent is “usable” is best assessed with three layers of evaluation:

    1. Terminal operation layer: success rates for command execution, file editing, dependency installation, and error recovery;
    2. Software engineering layer: patch correctness and regression pass rates on tasks in the style of real repositories;
    3. Stability layer: variance in success rate across repeated runs of the same task, average number of steps, and timeout rate.

    If a model that performs close to the state of the art on a terminal benchmark also shows transfer gains on a software engineering benchmark, it has learned “reusable engineering behavior” rather than surface tricks tailored to a single environment.

    6. A Reproducible Recipe Checklist (Teams Can Follow Directly)

    • Build a task pool: each task ships with its own snapshot, verification script, timeout, and resource limits;
    • Design the reward: prefer verifiable 0/1, and add graded rewards such as “compiles / some tests pass” when necessary;
    • Adopt full-parameter reinforcement learning: combined with parallel partitioning and recomputation, with sampling decoupled from training;
    • Apply cost control: trajectory compression, curriculum learning, tiered inference intensity, and environment caching;
    • Build an observability system: reward curves, failure clustering, resource heatmaps, and alerts;
    • Finally, run transfer evaluation: cross-validate across terminal tasks, repository-level tasks, and stability.

    7. Conclusion

    The key to training a usable agent within a small compute window is not any single trick, but closing the loop on four things: verifiable tasks, full-parameter reinforcement learning, decomposable cost, and transferable evaluation. For developers and enterprises, the greatest value of this approach is obtaining agent engineering capability that is more explainable and more reproducible, with a more controllable budget.