Million-Token Context and Trillion-Parameter Models: A Practical Guide to Post-Training, Evaluation, and AI Agent Engineering

    This article examines the shift in how large models gain capability—away from simply scaling pretraining and toward post-training through supervised fine-tuning, preference optimization, and reinforcement learning. It explains why multiplying compute does not automatically multiply results, breaks down the framework, environment, and efficiency layers of a production post-training pipeline, and argues for evaluating models in real, long-horizon environments rather than static benchmarks. It also covers the engineering realities of trillion-parameter models and million-token contexts, and closes with a step-by-step approach to building your own agent evaluation and integration system.

    1. From Stacking Pretraining to Stacking Post-Training

    Over the past few years, the growth of large models has been driven by one main thread: scaling parameter count, data volume, and compute in tandem. By 2026, however, two signals have become increasingly clear. Trillion-parameter models are no longer rare, and million-token context is becoming a baseline configuration for leading models. At the same time, the marginal returns from scaling pretraining alone are diminishing. High-quality public corpora are increasingly scarce, and pouring more compute into ever-larger pretraining runs yields improvements that fall short of expectations.

    As a result, the focus of competition is shifting toward post-training. Post-training is the stage in which, after pretraining is complete, a base model is aligned to target tasks and behavioral norms through supervised fine-tuning, preference optimization, and reinforcement learning. If pretraining determines “how much a model knows,” post-training determines “whether it can put that knowledge to use, and do so reliably.” Once a base model’s knowledge is rich enough, what determines whether it can handle real tasks is often its reasoning, execution, error correction, and long-horizon planning. These abilities are difficult to acquire from reading text alone; they must be practiced through repeated trial and error in interactive, verifiable environments—and reinforcement learning is the primary paradigm for this kind of training.

    A typical post-training loop works like this: the model generates multiple candidate trajectories for a batch of verifiable tasks, the environment automatically judges whether each trajectory achieves its goal, and the policy is updated accordingly.

    1. # Illustrative code: an RL post-training loop with sandbox isolation and quality checks (pseudocode)
    2. tasks = load_verifiable_tasks() # each task comes with an automatically executable verification script
    3. model = load_base_model()
    4. for step in range(total_steps):
    5. # 1) Distribute tasks to isolated sandboxes; each task gets a timeout, CPU/memory limits, and a network policy
    6. rollouts = sample_parallel(model, sample(tasks, batch_size), n_per_task=8)
    7. # 2) Judge results automatically, and record execution logs, tool calls, and error messages
    8. trajectories = []
    9. for traj in rollouts:
    10. sandbox = Sandbox(cpu_limit="2", memory_limit="4Gi", timeout=600, network="deny")
    11. reward, logs = run_and_verify(traj, sandbox, verify_script=traj.task.verify)
    12. if is_valid_environment(traj, logs): # filter out invalid samples caused by environment errors or buggy verification scripts
    13. trajectories.append((traj, reward))
    14. # 3) Compute group-level advantages, discard uninformative all-correct/all-wrong samples, and reduce variance
    15. advantages = group_normalized_advantages(trajectories, tasks)
    16. model.update(advantages)

    Three design points in this loop are worth highlighting:

    • Verifiable rewards are a prerequisite. Only tasks whose success can be judged automatically can produce training signals cheaply. Teams invest substantial engineering effort into converting real-world scenarios into a “task description + executable verification script” format.
    • Sampling is the cost. A single trajectory may involve dozens or even hundreds of tool calls. If executed serially, GPUs sit idle waiting for the environment to respond. Large-scale parallel sampling and fine-grained scheduling therefore become a necessity.
    • Environment quality sets the ceiling. A trajectory with “reward = 1” may stem from a loophole in the verification script or from a false positive after a failed sandbox initialization. Low-quality samples get repeatedly reinforced as positives, ultimately showing up as “strong benchmark performance but weak real-world behavior.”

    In short, post-training is not simply “adding more training steps.” It means scaling compute, environments, tasks, and infrastructure together. Investing in only one of them typically yields limited returns.

    2. Why 10x Compute Doesn’t Always Mean 10x Results

    To understand why scaling post-training is hard, it helps to see how reinforcement learning training differs architecturally from conventional model training. Conventional training can be abstracted as a one-way pipeline—forward pass, backpropagation, parameter update—with a steady rhythm at each stage that is easy to batch. Reinforcement learning training consists of two phases with very different rhythms:

    1. The sampling (rollout) phase: the model interacts with the environment repeatedly to generate complete trajectories. This phase depends on the inference engine, has high latency, and varies widely in duration depending on task difficulty and the environment.
    2. The optimization phase: rewards are computed, advantages are estimated, and gradients are applied to the sampled trajectories. This phase depends on the training framework, is compute-intensive, and has high throughput.

    This dual-engine “inference + training” structure means that whether post-training compute translates into capability depends on three conditions at once: whether the infrastructure can keep compute fully fed; whether tasks and rewards provide high-quality learning signals; and whether the evaluation system accurately reflects capability gains. If any one of these is a bottleneck, added compute is wasted.

    2.1 Framework layer: decoupling sampling from training

    In traditional synchronous designs, the optimization phase must wait for every trajectory in a batch to return, yet trajectory lengths often vary widely—so once short tasks finish, a large amount of compute sits idle. The solution is to decouple the two engines and support asynchronous sampling:

    1. # Illustrative code: an asynchronous RL training loop that decouples sampling from training
    2. async def async_rl_loop(model, task_pool, trainer, num_inflight=256):
    3. pending = set()
    4. while not training_finished():
    5. # Always keep roughly num_inflight tasks running in the environment; the GPU never waits for "the slowest one"
    6. while len(pending) < num_inflight:
    7. task = task_pool.next()
    8. pending.add(asyncio.create_task(rollout(model.snapshot(), task)))
    9. done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)
    10. for future in done:
    11. traj = await future
    12. trainer.enqueue(filter_and_score(traj)) # enqueue: quality filtering + reward computation
    13. if trainer.has_enough_data():
    14. trainer.step() # asynchronously perform one parameter update after enough samples have accumulated

    While asynchronous training improves throughput, it also introduces two new problems:

    • Stale policies: the model version used during sampling may lag the training version by several steps, which needs to be corrected with importance sampling or by limiting how stale it can get.
    • Scheduling pressure from long context: multi-turn trajectories routinely span hundreds of thousands of tokens, with large KV-cache footprints and heavy memory fragmentation. Prefix-cache reuse, chunked prefill, and similar techniques are therefore needed, combined with cache-affinity scheduling that routes different turns of the same task to the same instance as much as possible—significantly reducing repeated prefill overhead.

    2.2 Environment layer: the sandbox as an agent’s “practice ground”

    Every trial-and-error step by an agent comes with command execution, file modification, and sometimes network access. Without isolation, the training process itself can introduce security and stability risks. A production-grade sandbox typically provides the following capabilities:

    • Resource limits: caps on CPU, memory, disk, and execution time to prevent infinite loops or runaway processes from taking down a node.
    • Network isolation: outbound access is denied by default, with controlled dependency download endpoints allowed only via a whitelist when necessary.
    • Fast snapshot and rollback: after a trajectory fails, the environment can be restored to its initial state for the next trajectory to reuse, avoiding the cost of repeated initialization.
    • Runtime substrate: a common implementation combines a lightweight container with a micro-virtual machine. The former starts quickly and suits high-concurrency short tasks; the latter provides stronger isolation for security-sensitive scenarios.

    Equally important is environment quality inspection. When running joint training across hundreds of downstream domains, tasks submitted by different teams vary in difficulty, verifiability, and clarity of description. Without a unified admission and quality-control mechanism, low-quality tasks dilute the training signal and can even introduce erroneous behavior. An effective approach is to build a shared environment quality-assurance platform that runs the following checks before a task enters the training pool:

    • Automated pre-checks: whether the baseline model can complete the task; whether expert trajectories pass verification reliably; and whether the task can be completed through unintended shortcuts (such as hardcoding test inputs).
    • Manual spot checks: sampling tasks to review whether descriptions are clear and verification scripts are strict.

    2.3 Efficiency layer: making every unit of compute produce useful gradients

    Beyond idle time, invalid gradients are another major source of “leakage” in post-training compute. Common mitigation techniques include:

    • Difficulty stratification and curriculum sampling: in a given batch, all-correct and all-wrong tasks produce no useful relative advantage; controlling the proportion of each difficulty band improves sample information content.
    • Reward shaping: adding modest constraints on process quality (such as step soundness and resource consumption) prevents the model from learning opportunistic behavior that “chases only the final result.”
    • Scheduling systems: when training hundreds of tasks in parallel, you need sensible task queues, preemption policies, and fault tolerance so a single misbehaving environment doesn’t block an entire training batch.

    Only when these layers work together can the return on post-training compute grow roughly linearly with scale.

    3. Upgrading Evaluation: From Gaming Benchmarks to Real-Environment Testing

    Whether capability gains can be measured accurately is one of the most discussed questions in this round of technical iteration. Traditional benchmarks mostly use question-answering or single-turn code generation, which have three limitations:

    • They are disconnected from actual work scenarios;
    • They are easily covered by training data (benchmark contamination);
    • They cannot reflect multi-step, long-horizon execution ability.

    As a result, the industry is moving toward two more discriminating evaluation approaches: terminal-based coding benchmarks and enterprise-built long-horizon internal benchmarks.

    3.1 Terminal-based coding benchmarks: close to the real engineering environment

    Terminal-based evaluation assigns agents tasks in a command-line system that closely resembles a real development environment—for example, diagnosing a build failure, resolving a dependency conflict, or locating and fixing a defect. The model must combine commands, read and write files, and interpret error output like an engineer, all while completing the task within limited resources. The design centers on three points:

    • Resource constraints: limits on runtime, the scope of file changes, or network access test whether the model can make trade-offs within a budget.
    • Strict verification: each task has independent tests, and judgment is based solely on final results rather than the model’s self-report.
    • Realistic distribution: covering multiple engineering languages and project types reduces bias from any single scenario.

    The results of these benchmarks reflect a model’s usability in real development workflows better than “the pass rate of single-turn code generation.”

    3.2 Internal long-horizon benchmarks: filling the gaps of public benchmarks

    Public benchmarks are inevitably at risk of being covered by training data, so many teams build internal benchmarks that focus on the following capabilities:

    • Locating relevant logic across files in a large codebase;
    • Executing multiple subtasks in sequence while keeping the overall goal from drifting;
    • Dynamically adjusting plans based on intermediate results;
    • Correctly calling external tools and then summarizing and delivering the results.

    The key to such benchmarks is the “long horizon.” Short tasks can be completed through local reasoning, but long-horizon tasks require the model to still remember the original constraints dozens of steps in, even as context keeps accumulating. When measuring long-horizon ability, you should not look only at whether the final outcome succeeds—process metrics matter too:

    • Number of steps completed;
    • Tool-call success rate;
    • Number of self-corrections after errors;
    • Whether the model falls into unproductive loops.

    3.3 Statistical significance: how to read the gap after the decimal point

    Recent public results show that on some terminal-based benchmarks, the score gap between leading models has narrowed to one or two percentage points—for example, a comparison of roughly 66% versus roughly 58%. Faced with this situation, a few principles should guide the interpretation of evaluation results:

    • Look at the variance range. Sampling temperature, runtime environment, and task ordering all affect results; a single score is not comparable.
    • Look at difficulty stratification. Similar overall scores do not mean consistent performance across difficulty bands; differences on hard tasks often better predict real-world performance.
    • Look at process quality. At the same pass rate, a solution with fewer steps and lower resource consumption is more valuable in production.
    • Prioritize reproducibility. Evaluation scripts, dependency versions, and verification standards should all be fixed and public.

    A practical rule of thumb can be summarized as follows:

    1. # Illustrative code: compare two models on the same benchmark and judge whether the gap is statistically significant
    2. from math import sqrt
    3. def compare_models(scores_a, scores_b, alpha=0.05):
    4. """
    5. scores_a / scores_b: lists of task pass rates (0~1) from multiple independent runs of each model
    6. returns: mean difference, standard error, confidence interval of the difference, and whether the difference is significant
    7. """
    8. mean_a = sum(scores_a) / len(scores_a)
    9. mean_b = sum(scores_b) / len(scores_b)
    10. se = sqrt((var(scores_a) + var(scores_b)) / len(scores_a)) # standard error of the difference between the two means
    11. ci_low = (mean_a - mean_b) - 1.96 * se # approximate lower bound of the 95% confidence interval
    12. return {
    13. "mean_diff": mean_a - mean_b,
    14. "ci_95": (ci_low, ci_low + 2 * 1.96 * se),
    15. "significant": ci_low > 0, # the 95% confidence interval does not cross 0, so A is significantly better than B
    16. }

    When the confidence interval crosses zero, the so-called “lead” is more likely the result of random fluctuation. In such cases, decisions should draw on repeated evaluations and real business samples rather than a single leaderboard result.

    4. Trillion-Parameter Models and Million-Token Context: Capability Is the Ceiling, Engineering Is the Floor

    While discussing the ceiling on capability, it is equally important to consider engineering constraints. Trillion-parameter models and million-token contexts impose new demands on inference serving. Some teams adopt a “one model, two serving modes” strategy: model weights and inference precision stay the same, and only the serving layer is optimized for engineering. Two common misconceptions need clarifying here.

    4.1 “Fitting” the context is not the same as “using it well”

    Context length is the upper bound on the total number of available tokens, not a measure of effective information. The computational complexity of attention grows superlinearly with sequence length, and KV-cache memory usage rises linearly with length. In practice, techniques such as sparse attention and paged KV-cache management are used to reduce overhead, but long context still brings two problems:

    • Key information gets diluted: when there is too much irrelevant content, the model’s adherence to key instructions can decline—an issue often called “lost in the middle.”
    • Costs rise: the longer the input, the greater the prefill latency and memory pressure.

    For this reason, million-token context is better suited as an “extended capability,” used on demand in scenarios such as retrieval-augmented generation, long-document understanding, and large-codebase analysis, rather than stuffing all history into the context by default. Common engineering approaches include:

    1. Context compression: generate structured summaries for completed subtasks, keeping only conclusions and key constraints.
    2. Externalizing state: write intermediate artifacts to files or persistent storage, then read them back on demand.
    3. Retrieval instead of full inclusion: use vector retrieval and similar methods to recall only the snippets most relevant to the current step.
    4. Setting budget caps: impose a token limit on each turn’s input, triggering compression or summarization when exceeded.

    4.2 “Low latency” is not the same as “low intelligence”

    In long-horizon agent applications, response speed directly affects the experience. For example, a single complete task for a coding agent may require dozens of model calls, and every one-second increase in per-call output latency compounds the cumulative wait.

    The common approach to speeding things up is to optimize the inference pipeline while keeping model weights and output quality unchanged. Typical techniques include:

    • Speculative decoding: a small model drafts several candidate tokens, which the large model then verifies in a single pass, reducing the number of serial decoding steps;
    • Operator and precision optimization: operator fusion, mixed precision, quantization, and so on;
    • Batching and scheduling optimization: continuous batching and request-priority scheduling;
    • Context-cache reuse: reusing cached fixed prefixes such as system prompts and tool descriptions.

    It bears emphasis that the optimization target should be “end-to-end task latency,” not token output speed alone. A model that outputs faster but has a higher error rate often requires more rework, making total time longer. When evaluating a low-latency version, two things should be checked closely: whether the pass rate on the same task set matches the standard version, and whether first-token latency and sustained output remain stable.

    For developers, this “two-version” approach can be likened to the following: the model decides intelligence, the serving mode decides speed, and the business can choose flexibly by scenario.

    5. Putting It into Practice: Building Your Own Agent Evaluation and Integration System

    Once you understand the changes on both the capability and engineering sides, the more practical question is: how can you apply these capabilities in your own business while keeping quality under control? The following recommendations cover evaluation and integration.

    5.1 Build your own long-horizon evaluation set

    Public benchmarks can serve only as a reference; what is truly valuable is an evaluation set that matches your own task distribution. The steps can be summarized as follows:

    • Collect real tasks: select samples from historical tickets, bug reports, and code review comments that can be verified automatically.
    • Define success criteria: use objective signals such as “unit tests pass,” “build succeeds,” or “key metrics are met” as the basis for judgment, avoiding reliance on manual scoring.
    • Stratify and balance: divide tasks into tiers by type, difficulty, and domain, and set sampling ratios that reflect the actual distribution.
    • Fix the runtime environment: run evaluations in containerized environments with fixed dependency versions and verification scripts to ensure reproducibility.
    • Keep updating: inject new tasks regularly to prevent the evaluation set from losing its discriminating power over time.

    5.2 Phased integration and canary release

    A model upgrade should not be a “one-shot switch.” A more reliable path is as follows:

    • Offline evaluation: compare old and new versions on your own evaluation set, confirming that pass rate, latency, and cost are all within expected ranges.
    • Shadow traffic: let the new model process real requests in the background without returning results, to observe its behavior under the actual input distribution.
    • Small-traffic canary: roll out gradually by percentage, monitoring metrics such as success rate, average number of turns, and timeout rate.
    • Full rollout: retain the ability to roll back quickly, with rollback decisions based on thresholds defined in advance.

    5.3 Cost and stability control

    A single call to a trillion-parameter model in long-context scenarios is not cheap, so costs must be controlled at the system-design level:

    • Route by task difficulty: use lightweight models or rule-based handling for simple tasks, and reserve large models for complex ones.
    • Limit maximum turns and the token budget: prevent the agent from falling into unproductive loops.
    • Structure the context: pass in only necessary information to reduce redundant tokens.
    • Cache results: cache and reuse intermediate results for repeated queries.

    6. How to Think About “Capability Improvement”

    Viewing this round of technical change over a longer time horizon yields a relatively clear judgment: the capability boundary of base models is being pushed to new heights, while the ultimate effectiveness of applications will depend increasingly on how the engineering side organizes and uses those capabilities.

    A few trends are worth noting:

    • The sources of capability improvement are changing. The rising weight of post-training and reinforcement learning means that the ability to build “verifiable tasks” is becoming part of a model team’s core competitiveness. Teams that can define tasks well and design good verification standards find it easier to turn compute into results.
    • Evaluation is shifting from “static Q&A” to “dynamic execution.” The rise of terminal-based and long-horizon benchmarks stems from the fact that real work is not a single question-and-answer, but a series of decisions with feedback.
    • Engineering constraints matter as much as capability. Context, latency, and cost are not “beyond capability” issues—they are prerequisites for whether capability can land.
    • The takeaway for developers: rather than chasing leaderboard scores, build your own task-verification system first. Models will keep iterating, but a high-quality evaluation and integration system is a long-term, reusable asset.

    Overall, the message of this round of updates can be condensed into three sentences:

    • The ceiling on capability depends on the depth of the training method, not just parameter scale;
    • Evaluation is moving toward real environments and long-horizon tasks, so the meaning of a single score is declining;
    • The engineering side must address context management, latency optimization, and cost control together to make capability land reliably.

    For teams planning agent systems, a sensible approach is to first build a set of automatically verifiable tasks, then choose models that perform reliably and have controllable latency on your task distribution, and finally roll out gradually through canary releases and monitoring. Models are just tools; what ultimately determines the quality of the output is still task definition and engineering execution.