LLM Post-Training in Practice: Building Long-Horizon Agent Capabilities
The center of gravity in large model capability growth is shifting from pre-training to post-training. This article explains why supervised fine-tuning and reinforcement learning have become the decisive factor for real demands like coding, repeated tool use, and multi-step problem solving, and how verifiable rewards make large-scale RL across many domains practical. It covers terminal-environment evaluation of code agents, long-horizon testing, ultra-long context and state management, the infrastructure needed for large-scale joint training, and the role of hosted agent runtimes. It closes with evaluation guidance and practical recommendations for teams building long-horizon agents.
1. Capability Growth Is Shifting from Pre-Training to Post-Training
Historically, the industry measured a large model’s ceiling by parameter count and pre-training data volume. But when facing real demands—“write working code,” “call tools repeatedly,” “complete a multi-step task end to end”—simply scaling pre-training compute is delivering diminishing returns. The real dividing line is post-training: using supervised fine-tuning (SFT) and reinforcement learning (RL) to turn what a model “can do” into what it “does correctly and reliably, step after step.”
The value of post-training lies in aligning the behavior distribution. Pre-training gives a model broad world knowledge and language ability; post-training compresses that ability onto the success distribution of specific tasks. When a model must read files in a terminal, run tests, inspect errors, and patch its own code in a loop, what matters is not “knowing the answer” but “choosing the right action at every step.” This kind of ability is hard to learn from static corpora—it must be shaped through interaction with an environment and the feedback that interaction produces.
Hence a notable trend: shifting a larger share of the total compute budget from pre-training to post-training, and extending reinforcement learning to as many downstream domains as possible. This is not simply “training a little longer,” but a structural shift in the training paradigm.
2. Scaling Reinforcement Learning Across Domains: Where Do Rewards Come From?
The hard part of reinforcement learning has never been the algorithm—it’s the reward signal. Classic RLHF relies on human preference labels, which are costly and narrow in coverage. To scale RL across hundreds of downstream tasks, a more practical path is verifiable rewards: any task whose outcome can be judged automatically can be turned directly into a reward signal.
# Verifiable reward logic (illustrative)def compute_reward(task, agent_output):result = run_in_sandbox(agent_output) # Execute in an isolated environmentif unit_tests_pass(result): # Unit tests passreturn +1.0if compile_or_lint_ok(result): # Compilation or lint checks passreturn +0.5return 0.0 # No penalty for failure, to avoid gradient oscillation
Code tasks are a natural fit for this paradigm: whether code compiles, whether tests pass, whether a command returns the expected exit code—these are objective, reproducible criteria. Tasks like financial research, structured reasoning, and tool calling can similarly encode “result correctness” into rewards through validators. The advantage is that the reward cannot be fooled by “rhetoric”: the model must actually solve the problem to earn positive feedback, which suppresses the degenerate pattern of “looks like an answer but is empty talk.”
Engineering-wise, sparse rewards and training stability also need handling: too sparse a reward slows convergence, while too dense a reward invites reward hacking. Common approaches include layered rewards, curriculum learning (easy to hard), and weighted sampling across domains, to prevent the model from overfitting one high-reward area and neglecting others.
3. Code and Terminal Agents: Why “Real Environments” Matter for Evaluation
Code and long-horizon tasks are the clearest beneficiaries of this round of post-training, and evaluation methods are evolving alongside. Traditional code benchmarks are mostly single-turn—“given a prompt, produce code”—and cannot reflect real development scenarios. A more convincing approach is terminal-environment evaluation: in a resource-constrained sandbox with a full toolset, the agent is given a complex task, each paired with a dedicated test suite. The agent must explore the environment, execute commands, read logs, and iterate on fixes on its own, with success ultimately judged by whether the tests pass.
What makes this evaluation hard is that it turns “writing code” into “completing a task.” The agent must handle a chain of decisions—context management, error recovery, tool selection—and a break in any link causes failure. It tests the model’s planning ability, self-correction, and endurance over long workflows, rather than single-point code generation accuracy.
Long-horizon code testing stretches the time span further: tasks often require tens or hundreds of steps to complete, with misleading errors along the way, judgments that require backtracking, and cascading changes across multiple files. When evaluating long-horizon capability, a key metric is how fast the task completion rate decays as the number of steps grows—the slower the decay, the stronger the model’s stability and state-retention ability. This is also why verbosity, narrow focus, and “forgetting the goal” midway are the problems most closely watched in these evaluations.
4. Ultra-Long Context and State Management
Long-horizon tasks place extreme demands on context. When an agent must still remember the original constraints after dozens of steps, reconstruct the file structures created along the way, and distinguish “verified” from “unverified” information, an ultra-long context window goes from a nice-to-have to a necessity.
But “the window is long enough” is not enough on its own—what truly determines success is context engineering:
- Information compression: Summarize or trim lengthy tool returns and log output, keeping only decision-relevant information so irrelevant content doesn’t crowd out the attention budget.
- State externalization: Write task progress, completed sub-goals, and key intermediate results to external memory (files, structured storage) rather than piling everything into the context, and pull them back on demand via retrieval.
- Attention preservation: The “lost in the middle” effect in long contexts is real; place critical instructions and goals in high-weight positions and restate them periodically.
A pragmatic judgment: ultra-long context should work together with retrieval and external memory, not replace information management with an ever-growing window. The window is capacity; context engineering is utilization.
5. Infrastructure for Large-Scale Joint Training
To run reinforcement learning across hundreds of domains simultaneously, the model and algorithms are only the tip of the iceberg—the real strain is on infrastructure. A working system typically needs to rework the following:
- RL training framework: Adopt an architecture that separates generation (rollout) from learning (learner), so an inference cluster produces trajectories while a training cluster updates parameters, with the two decoupled through an efficient data channel to maximize GPU utilization.
- Sandbox infrastructure: Every task must safely execute arbitrary commands in an isolated environment, involving container orchestration, resource quotas, network isolation, and fast snapshot/rollback, so that thousands of concurrent trajectories don’t interfere with one another.
- Scheduling system: Orchestrate a large number of tasks of varying lengths on heterogeneous compute, handling preemption, priorities, and failure retries.
- Environment quality checks: Batch-verify whether task environments are actually solvable, whether grading is correct, and whether there are loopholes that leak answers, to avoid contaminating training signals with “bad problems.”
These components typically rely on mature cloud-native capabilities—for example, container platforms for sandbox orchestration, object storage and message queues for trajectory data and task distribution, and logging plus monitoring and alerting to maintain visibility across large-scale training. General-purpose cloud infrastructure offerings such as those from Baidu AI Cloud are a common foundation for building such systems.
6. Hosted Agents: Turning the Agent Runtime into Cloud Infrastructure
An often-overlooked but production-critical concept is the runtime harness that keeps an agent running over long periods. The model itself is only the decision core; what actually lets an agent work continuously around the clock, maintain state across steps, retry and recover automatically on failure, and support multiple agents collaborating, is this runtime layer wrapped around the model.
Making this runtime a managed cloud service means enterprises and developers don’t have to build their own sandbox, scheduling, state storage, and recovery mechanisms—they can directly call a hosted environment capable of running long-horizon tasks. Its value is turning a complex engineering problem—“how to let agents run safely and stably for a long time”—into a callable infrastructure capability. For users, the focus shifts from “how to build the environment” back to “how to define the task and its acceptance criteria.”
7. Evaluation Methods and Selection Guidance
Faced with a flood of capability claims, developers should keep a clear-headed evaluation perspective:
- Check whether the evaluation reflects real scenarios: Single-turn Q&A scores cannot represent a terminal agent’s real-world ability; prioritize evaluations with tools, environments, and dedicated tests.
- Look at long-horizon stability, not peak performance: Passing a simple task doesn’t mean finishing a complex workflow; watch the decay curve of task completion rate as steps increase.
- Beware data contamination: Public benchmarks may be covered by training data; cross-validate with a self-built internal evaluation set.
- Distinguish “model capability” from “runtime capability”: The same model with a better runtime harness can differ significantly on long-horizon performance; evaluate both together when making a selection.
8. Practical Recommendations for Adoption
For teams looking to build long-horizon agents, the following path can help:
- Define verifiable success criteria first: Translate “task complete” into tests and validators that run automatically—this is the prerequisite for doing RL and iterating automatically.
- Invest in the runtime, not just the model: Making the sandbox, state management, and failure recovery solid often yields more stable gains than swapping models.
- Use context engineering to control complexity: Counter information bloat in long contexts with external memory and retrieval.
- Build a layered evaluation system: Validate progressively from unit tests to end-to-end long-horizon tasks, avoiding being misled by single-point metrics.
In summary, the leap in long-horizon agent capability is not a single-point breakthrough in any one technology, but the combined result of the post-training paradigm, verifiable rewards, infrastructure, and a runtime harness. Understanding this chain is what allows for rational judgment amid rapidly evolving capabilities and for landing the right combination of technologies in your own business scenarios.
