Post-Training at Trillion-Parameter Scale: Scaling RL for Coding and Long-Horizon Agents
This article examines why post-training scale, rather than pretraining alone, has become the dividing line for large model capability. It walks through the five infrastructure layers required to scale reinforcement learning across hundreds of task domains — decoupled RL frameworks, long-context inference, training efficiency, sandbox infrastructure, and scheduling with environment quality control — then covers evaluation methodology for coding agents in real, resource-constrained terminals and the three pillars of long-horizon tasks. It closes with a hosted agent architecture (orchestration, execution, state, governance) and a practical checklist of common pitfalls. Readers will get concrete engineering patterns, a reference agent loop, and guidance on separating model failures from environment failures in RL data pipelines.
Post-Training at Trillion-Parameter Scale: Scaling RL for Coding and Long-Horizon Agents
1. Why post-training scale has become the capability dividing line
Over the past two years, the industry’s focus on large model capability has shifted from pretraining to post-training. Pretraining determines the breadth of a model’s knowledge and its baseline language understanding, but what really decides whether a model can keep working through a task is usually the post-training stage — in particular, reinforcement learning (RL) applied at scale in real task environments.
Current mainstream practice shows a clear trend: post-training compute investment keeps growing, and the downstream task domains covered by RL have expanded from the early two or three areas such as math and code to hundreds of specialized subdomains. This expansion is not simply “training a few more rounds.” It triggers a chain of system-level changes:
- The training framework must support high-throughput rollout sampling decoupled from policy updates.
- Long-context inference must keep throughput and cost under control at hundreds of thousands to millions of tokens.
- Training efficiency depends on parallelism strategies, communication optimization, and operator-level tuning.
- Sandbox infrastructure must provide safely isolated execution environments for massively concurrent tasks.
- Scheduling and environment quality platforms must guarantee consistency and reproducibility across thousands of concurrent environments.
All five are indispensable. A weak link in any one of them turns “scaling up RL” into a slogan that cannot be delivered on.
2. Five infrastructure layers that support large-scale RL
2.1 RL framework: decoupling sampling from training
The core tension in large-scale RL is that policy updates (GPU-intensive) and environment interaction (often CPU/IO-intensive) run at completely different rhythms. The standard engineering answer is to split the system into an asynchronous pipeline:
- Rollout service: generates trajectories in batches, with dynamic batch sizing and priority scheduling.
- Reward service: combines rule-based, model-based, and human review scoring.
- Trainer service: consumes the experience replay pool and performs policy-gradient / PPO-style updates.
A message queue decouples the three, which both tolerates the long-tail latency of environment execution and keeps GPU utilization high.
2.2 Long-context inference: the engineering reality at a million tokens
Long context is not just about being able to fit content in; it is about being able to afford it and run it fast. The key techniques include:
- KV cache reuse and paged management: in multi-turn agent tasks the prefix often stays unchanged, so cache hits can substantially cut input cost.
- Context compression and summarization: in long-horizon tasks, periodically compress history into a structured state to avoid attention dilution.
- Retrieval augmentation and externalized tools: keep bulky material in external storage and retrieve it on demand instead of stuffing everything into the context.
2.3 Training efficiency: parallelism and communication overlap
Joint training at the trillion-parameter level requires combining data parallelism, tensor parallelism, pipeline parallelism, and expert parallelism, while overlapping gradient communication with forward and backward computation. The RL stage also needs a dedicated broadcast mechanism for its frequent weight synchronization, so that long-tail rollouts do not slow down the whole iteration.
2.4 Sandbox infrastructure
Code and agent tasks require the model to actually run commands, install dependencies, and execute tests. The sandbox needs to provide:
- Strong isolation: network allowlists, filesystem isolation, resource quotas (CPU/memory/time).
- Reproducibility: versioned base images, locked dependencies, environment snapshots.
- High concurrency: fast container- or micro-VM-level creation and teardown, with cold starts kept to seconds.
- Observability: full stdout/stderr capture, exit codes, and resource consumption records for reward computation and post-hoc auditing.
2.5 Scheduling and environment quality
Once concurrent environments reach the thousands, “the environment broke” and “the model answered wrong” must be distinguishable. A common approach is to add startup self-checks, dependency integrity validation, and golden-case regression to every environment. The scheduler circuit-breaks and retries timed-out or hung tasks, and writes failure attribution (environment failure vs. task failure) into the metadata of training samples, so dirty data does not pollute the RL signal.
3. Coding and long-horizon agents: capability and evaluation methodology
3.1 Evaluation in real terminal environments
The industry increasingly emphasizes evaluating coding agents in real, resource-constrained terminal environments: each task comes with its own repository, dependencies, and dedicated tests, and the model must autonomously explore, edit, execute, and repair. Compared with static “completion-style” code benchmarks, this kind of evaluation better reflects engineering usability because it introduces:
- Non-determinism (network, dependency versions, filesystem state).
- Multi-step correction loops (run tests → locate the failure → modify → rerun).
- The ability to make tradeoffs under time and resource constraints.
3.2 The three pillars of long-horizon tasks
Long-horizon tasks often last tens of minutes or longer, and the model needs:
- Task decomposition and planning: break the goal into verifiable subtasks and maintain todo state.
- State persistence: keep checkpoints, logs, and intermediate artifacts outside the context.
- Self-verification: proactively run tests, read the results, and decide whether to continue, roll back, or ask for help.
A practical agent main loop can be abstracted as follows (pseudocode):
while not task.done:state = harness.load_state() # restore from checkpointobs = env.observe()action = model.plan(obs, state)result = env.execute(action) # execute inside the sandboxharness.save_state(result)if result.timeout or result.error:env = harness.reset_or_rollback() # circuit-break and roll backif harness.checkpoint_needed():harness.snapshot() # persist a context summary
4. Designing a hosted agent architecture
Supporting 24/7 long-horizon tasks and multi-agent collaboration takes more than a model API. The agent runtime (harness) has to be productized as cloud infrastructure. A typical architecture includes:
- Orchestration layer: task queues, dependency DAGs, scheduled triggers, and failure retries.
- Execution layer: an elastic sandbox pool and a tool gateway (code execution, browser, retrieval, file operations).
- State layer: checkpoint storage, shared memory, and event streams. This can be built from general-purpose cloud products — for example, combining the container platform and object storage on Baidu AI Cloud.
- Governance layer: budget control (tokens/compute/duration), permission boundaries, audit logs, monitoring and alerting.
Multi-agent collaboration usually follows an “orchestrator–executor” pattern: the orchestrator handles task decomposition and result aggregation, while executors focus on specific subdomains (code implementation, test verification, financial data retrieval). They exchange structured messages over a message bus rather than long natural-language text, which reduces information loss.
5. Implementation checklist and common pitfalls
- Environment consistency comes before model fine-tuning. Many apparent “capability gaps” are actually failures caused by configuration drift. Pin images and golden cases first.
- Treat evaluation as a continuous asset. Build an internal long-horizon benchmark covering target domains such as code, research, and tool calling, and run a full regression on every training iteration.
- Model budget and timeouts explicitly. Cost overruns in long-horizon tasks usually come from unbounded retry loops.
- Separate model failure from environment failure. Keep attribution labels in the RL data pipeline, otherwise the reward signal gets drowned in noise.
- Build observability from day one. Structured logs, trajectory replay, and cost dashboards are the foundation for all later optimization.
6. Summary
The shift of large model capability from “one-shot question answering” to “continuously getting work done” is driven by the joint evolution of post-training scale, real-environment evaluation, and infrastructure engineering. Coding and long-horizon agents are the two most representative directions in this shift: the former requires the model to self-correct inside a real terminal, while the latter requires the system to preserve state, budget, and safety boundaries across tasks lasting hours or even days. For developers, the real competitive moat is no longer the model alone, but the ability to turn the RL data pipeline, sandboxes, scheduling, and the hosted runtime into a reliable engineering system. Understanding this methodology is what makes it possible to build applications that genuinely get work done in the agent era.
