Trillion-Parameter Models and Million-Token Contexts: Post-Training and Long-Horizon Agent Engineering Practices
This article examines how this generation of large models has moved beyond simply scaling parameters and context length. The key focus is now on post-training, long-context usability, long-horizon agent infrastructure, and unit-task cost. It covers practical engineering challenges in million-token context systems, including positional extrapolation, attention cost, KV cache management, and evaluation design. It also explains how reinforcement learning can be expanded across hundreds of domains by building verifiable reward signals, how long-horizon agents need a robust harness and sandbox, how training frameworks can support asynchronous rollout workloads, how faster model variants gain 2–3x speed, how token pricing affects real task cost, and what enterprises should do to deploy these systems reliably.
1. The Real Shift in This Model Generation: From “Bigger” to “Able to Keep Working”
Over the past two years, the main narrative around large-model progress has been parameter scale and context length. But the latest model upgrades show a clear shift in focus. Total parameter counts continue to grow into the trillion range, often using a sparse mixture-of-experts structure where only a small subset of parameters is activated during each forward pass. At the same time, much of the incremental investment is going into post-training, especially expanding reinforcement learning from a small number of tasks to hundreds of downstream scenarios.
Behind this shift is a practical judgment: pretraining determines the upper bound of a model’s knowledge, but post-training determines whether the model can work continuously for tens of minutes or hundreds of steps in a real working environment without drifting off track. For an agent that needs to fix a defect in a real code repository, or one that needs to continuously retrieve information and write an industry research report, this capability is the dividing line between usable output and unreliable output.
For this reason, evaluating this generation of models should focus on four engineering dimensions, rather than on a single leaderboard score:
- Is long context actually usable? The key question is not how large the context window is, but whether multi-hop reasoning remains stable at high context fill rates, such as 80%.
- Can post-training expand across domains? Reinforcement learning must be able to operate across hundreds of domains without causing different capabilities to damage one another.
- Is agent infrastructure complete? This includes sandboxes, snapshots, scheduling, and environment-quality checks.
- Is unit-task cost controllable? A lower unit price does not necessarily mean a lower total bill.
2. Million-Token Context: The Hard Part Is Attention and Memory, Not the Window Size
Expanding the context window from 128K tokens to 1 million tokens is not just a configuration change. At least four technical hurdles must be addressed.
Positional extrapolation and consistency with the training distribution. Positional relationships learned on short sequences degrade quickly when directly extrapolated to million-token lengths. A common approach is to expand the window in stages. First, position encoding interpolation or scaling is trained on medium-length sequences. Then, training continues on longer samples so that attention can actually encounter long-range dependencies. Finally, synthetic long-document tasks are used for alignment.
Attention computation and bandwidth cost. Standard full attention grows quadratically with sequence length. In practice, systems usually combine several techniques:
- Sparse or sliding-window attention;
- Block-level sparsity and local-global mixed attention;
- Chunked prefill, which splits an extremely long prompt into segments and processes them in a pipeline so that activation memory does not spike in a single step.
KV cache is the real bottleneck. During decoding, every generated token requires reading the full historical KV cache. In long-context scenarios, decoding is often almost entirely limited by memory bandwidth. Common approaches include:
- Paged KV cache management to reduce fragmentation and support shared prefixes;
- KV cache quantization, such as INT8 or FP8 storage;
- Prefix reuse across requests.
# Example: prefix sharing and hit tracking for paged KV cacheclass PrefixCache:def __init__(self, block_tokens=16):self.block_tokens = block_tokensself.blocks = {} # block_hash -> kv_blockself.ref_count = {}def match(self, token_ids):hit = 0for i in range(0, len(token_ids) - self.block_tokens + 1, self.block_tokens):h = self._hash(token_ids, i)if h in self.blocks:hit += self.block_tokens # matched tokens do not need to be prefilled againelse:break # once the prefix breaks, later blocks cannot be reusedreturn hitdef acquire(self, token_ids):# Stable prefixes such as system prompts, tool definitions, and long documents# should be placed at the beginning of the prompt so that block boundaries# remain stable and cache hit rates are maximized....
Evaluation traps must be identified early. A single needle-in-a-haystack test can prove that a model can find a fact, but it cannot prove that the model can perform multi-hop reasoning across chapters, compare conflicting evidence, or summarize the entire context. In real business scenarios, two problems are especially common: information in the middle of a long context becomes diluted, and retrieved snippets may contradict the original document. Therefore, long-context acceptance should include:
- Multi-hop question answering across paragraphs;
- Conflict resolution between pieces of information;
- Refusal behavior when the context does not contain the answer.
3. Post-Training: The Core Difficulty in Scaling RL to Hundreds of Domains Is Where Rewards Come From
For large-scale joint training, the real engineering challenge is not the algorithm itself, but the verifiability gradient of reward signals.
- Tier 1: There is a unique answer. Mathematics and logical reasoning can be verified with rules. The reward signal is relatively clean, and these tasks are often covered first by RL.
- Tier 2: Tests can be run. Code generation and terminal operations can use unit-test pass rates or final-state checks as rewards. This tier is a major source of long-horizon agent capability and is one of the focuses of this model generation.
- Tier 3: Preference models or human annotation are required. Writing, financial research, and 3D content creation are multi-dimensional and subjective. Reward hacking is easier here, because the model may learn to satisfy the evaluator rather than truly improve task quality.
Therefore, the engineering approach to cross-domain expansion is:
- Build automatically executable verifiers for each domain;
- Unify them into a common interface so that RL sampling and scoring can run in the same framework in parallel;
- Use domain sampling ratios and curriculum learning to control difficulty distribution;
- Prevent high-reward-density domains from consuming most of the gradient, which can cause other capabilities to regress.
4. Long-Horizon Agents: The Model Is the Engine, but the Harness and Sandbox Are the Vehicle
With the same model, a poorly designed agent runtime can produce long-horizon success rates that are more than twice as low as those of a well-designed runtime. A usable harness should solve at least five problems:
- Context management. When history exceeds the budget, perform structured compression rather than simple truncation. Preserve task goals, completed steps, key file paths, failed attempts, and the reasons for failure.
- Memory and state externalization. Write todos and intermediate artifacts to external storage or files, and keep only an index in the context.
- Failure recovery. Distinguish between retryable failures, such as tool timeouts or rate limits, and failures that require a strategy change. Add no-progress detection.
- Budget control. Set limits for steps, tokens, and wall-clock time. When limits are exceeded, terminate gracefully and return intermediate conclusions.
- Multi-agent collaboration. A main agent handles planning, while sub-agents perform fan-out retrieval or local verification. Their results are then summarized back into the main context.
# Example: agent main loop with budget control and context compressionasync def run(task, cfg):state = TaskState(goal=task, plan=[], artifacts=ArtifactStore())while not state.done:if state.budget.exceeded(): # step/token/time guardrailsreturn state.partial_report()ctx = build_context(state, max_tokens=cfg.ctx_budget)action = await model.act(ctx, tools=state.tool_schemas)try:result = await dispatch(action, sandbox=state.sandbox, timeout=cfg.step_timeout)except RetryableError as e:state.record_failure(action, reason=str(e))continueif is_no_progress(state, window=cfg.stall_window): # no-progress detectionstate.force_replan()state.apply(result)state.artifacts.persist(result) # externalize artifacts; keep only an index in contextreturn state.final_report()
The supporting sandbox infrastructure is equally important. It should include:
- Process and file-system isolation;
- Network egress allowlists;
- Rollback-capable file systems or container snapshots;
- CPU, memory, and runtime limits;
- Quality checks on the environment itself.
The last point is often overlooked. If the test environment itself is defective, the model may misjudge task difficulty or even modify tests just to “pass.” This kind of noise can directly contaminate the reward signal used in reinforcement learning.
5. Framework Changes Needed to Support Large-Scale Joint Training
To scale RL across hundreds of domains, the training framework must solve the problem of highly imbalanced sampling. For example, a code task rollout may finish in a few seconds, while a long-horizon research task may run for tens of minutes. If synchronous sampling is used, fast tasks must wait for the slowest task in the batch, which can significantly reduce GPU utilization.
Common framework-level changes include:
- Separating inference-engine resources from training-engine resources;
- Making rollout execution asynchronous and streaming results back;
- Estimating task duration and using length bucketing plus priority scheduling;
- Using hierarchical weight synchronization to reduce full-parameter broadcasts.
In addition, an environment-quality-checking platform should perform versioned validation of sandbox images. This is necessary to maintain stability when hundreds of domains are trained at the same time.
6. High-Speed Model Variants: Same Capability, 2–3x Faster
“Same intelligence, faster response” is a well-defined engineering path. Most of the speed gain comes from the decoding stage:
- Speculative decoding. A small model or n-gram drafts candidate tokens, and the large model verifies them in batches. The benefit is greatest for long outputs.
- Quantization. Weight quantization, such as FP8 or lower-bit formats, combined with KV cache quantization, directly reduces memory-bandwidth pressure.
- Prefill-decode disaggregation. Prefill and decoding have very different resource profiles. After separating deployment, each can use a suitable parallelism strategy.
- Continuous batching with higher concurrency. This improves throughput and can also reduce queueing latency for individual requests.
- Expert parallelism and routing optimization. For sparse models, load balancing is critical. Hot experts should not slow down the entire batch.
One important caveat is that speedup benefits are strongly related to output length. Short question-answering workloads may see limited improvement, while long-form generation and long-chain tool-calling workloads can see speedups close to 2–3x. This is consistent with the rule that longer outputs place a larger share of the workload in decoding.
7. Understanding Token Pricing: Four Dimensions and One Formula
The industry commonly uses a four-part pricing model:
- Input tokens without cache hits;
- Input tokens with cache hits;
- Cache writes or storage;
- Output tokens.
Cache-hit pricing is usually much lower than cache-miss pricing. Output token pricing is usually significantly higher than input token pricing, because decoding is serial and bandwidth-limited, making the compute cost per output token higher. High-speed variants are often priced at a multiple of the base model to cover the additional compute overhead.
The real driver of cost is unit-task cost, not the unit price:
Unit task cost = (cache-miss input × P_in_miss + cache-hit input × P_in_hit + output × P_out) × average number of retry rounds
There are three practical optimization points:
- Put stable prefixes first. Place system prompts, tool definitions, and long-term documents at the beginning of the prompt to maximize prefix-cache hit rates. Move content that changes over time, such as timestamps and random IDs, to the end of the prompt.
- Use retrieval instead of stuffing. Instead of inserting an entire manual into the context, retrieve only the relevant snippets. This reduces noise and cost at the same time.
- Compress tool returns. Tool output is often the bulkiest part of the context. Truncating large files, returning paginated results, and sending back only structured summaries can reduce both input and output tokens.
8. Enterprise Adoption Recommendations
Task tiering. Divide business tasks into three categories:
- Automatically verifiable tasks, such as those with tests or a unique final state;
- Semi-verifiable tasks, such as those with rules but exceptions;
- Non-verifiable tasks, which require human review.
Only the first two categories should be handed to long-horizon agents for full autonomous execution.
Evaluation systems. Use offline benchmarks for regression testing, online shadow runs to compare new and old versions, and human spot checks for calibration. Focus on the final-state correctness of long tasks rather than how polished each step looks.
Cost guardrails. Set token and runtime limits for each task, cap maximum concurrency, and automatically fall back to human handling after repeated failures.
Permissions and security. Apply least-privilege principles. Write operations should require approval. Retain audit logs for tool calls and data egress, especially when agents are connected to internal systems.
Infrastructure selection. General cloud capabilities—elastic containers, object storage, message queues, logging, monitoring, and alerting—are usually enough to support this architecture. General product categories, such as those offered by Baidu AI Cloud, can be combined as needed. The key is to treat sandbox snapshots, task scheduling, and observability as first-class design elements.
9. Conclusion
This generation of models shows that competition has shifted from “parameters and context windows” to a triangle made of post-training compute, agent infrastructure, and unit-task cost.
For developers and enterprises, chasing small differences in leaderboard scores is less useful than investing in three areas with clear returns:
- Build automatically verifiable task environments and reward signals.
- Improve the harness for context management and failure recovery.
- Use stable prefixes and budget guardrails to make token bills predictable.
If these three things are done well, the benefits of every model iteration can be absorbed directly by real business workflows.
