Improving Long-Horizon Agent Capabilities in LLMs: Post-Training, RL Infrastructure, and Evaluation

    This article examines how post-training and large-scale reinforcement learning support long-horizon agent capability gains, why compute-to-capability conversion efficiency matters, how to design reproducible agent evaluations, and how teams can choose between standard and low-latency model variants and use long-context capabilities in production.

    Improving Long-Horizon Agent Capabilities in LLMs: Post-Training, RL Infrastructure, and Evaluation

    1. Background: The Focus of Capability Improvement Is Shifting to Post-Training

    For the past several years, improvements in large model capabilities have relied mainly on data scale and parameter scale during pre-training. As the growth of available data slows, post-training has gradually become the main lever for capability iteration. Post-training typically includes supervised fine-tuning and reinforcement learning-based optimization. Reinforcement learning allows a model to repeatedly trial and error in verifiable task environments, thereby strengthening capabilities such as multi-step reasoning, tool calling, and task planning.

    This shift has a direct consequence: the more compute is invested in post-training, the broader the range of task domains the model can cover. However, compute itself does not automatically translate into capability. If the training infrastructure is unstable, environment quality is uncontrolled, or scheduling efficiency is low, a large amount of compute will be wasted on invalid samples. Therefore, judging whether a post-training run is successful requires looking not only at final metrics but also at the conversion efficiency from compute to capability.

    1.1 Why Compute-to-Capability Conversion Efficiency Is a Key Metric

    With the same compute budget, the results produced under different engineering conditions can differ significantly. Common losses come from three areas: invalidated samples caused by environment execution failures, waiting time caused by insufficient inference throughput, and data pipeline blocking between training and sampling. Teams often measure this efficiency using “valid samples per unit of compute” or “task pass rate improvement per unit cost.”

    2. Engineering Support for Large-Scale Reinforcement Learning Training

    Large-scale reinforcement learning training involves multiple interdependent system layers. A bottleneck in any layer will slow down overall progress. Common key components in the industry are as follows.

    • Reinforcement learning training framework: Responsible for scheduling policy updates, experience replay, and reward computation. It needs to support asynchronous sampling and distributed gradient synchronization.
    • Long-context inference service: Models during training often need to process long interaction histories. The inference side must address memory usage, KV cache management, and batching efficiency.
    • Training efficiency optimization: Includes mixed-precision computation, communication and computation overlap, gradient accumulation strategies, and other techniques. The goal is to obtain more effective updates on the same hardware.
    • Sandbox execution environment: Agent tasks require executing commands, reading and writing files, and calling tools in isolated environments. The sandbox must ensure controllable resources, resettable state, and prevention of interference between tasks.
    • Scheduling system: Needs to allocate compute across hundreds of downstream task domains while balancing fairness and priority and avoiding long-term starvation in certain domains.
    • Environment quality check platform: Training environments themselves may contain incorrect test cases, unstable dependencies, or inconsistent reward signals. Automated validation before environments enter training can significantly reduce invalid samples.

    The common goal of these components is to ensure that each additional batch of compute is stably converted into model capability rather than amplifying noise.

    3. Evaluation Approaches for Long-Horizon Agent Tasks

    Agent tasks differ from single-turn question answering. The model needs to continuously execute multiple steps in a real or simulated environment, and the output of each step affects subsequent states. Typical characteristics of such tasks are many steps, strong state dependencies, and hidden failure causes.

    Completing tasks in resource-constrained terminal environments is a common form of evaluating agent capabilities. Evaluators typically configure an independent initial state, clear completion conditions, and strict specialized test scripts for each task. The final metric is generally task pass rate, meaning the proportion of tasks that pass all tests.

    3.1 Principles for Evaluation Design

    1. Task isolation: Each task uses an independent initialized environment to prevent residual files or processes from previous tasks from affecting results.
    2. Verifiable tests: Completion conditions should be determined by scripts rather than manual subjective scoring, ensuring reproducible results.
    3. Explicit resource constraints: Memory, time, step count, and other limits should be clearly defined; otherwise, comparisons between different approaches are meaningless.
    4. Failure attribution: Record whether failures occur in planning, tool calling, or final verification so that improvement directions can be identified.

    Below is a generic evaluation framework skeleton for organizing task execution and result statistics. The functions in the example are placeholder implementations and need to be replaced according to the actual environment.

    1. from dataclasses import dataclass, field
    2. from typing import Callable, List
    3. @dataclass
    4. class TaskResult:
    5. task_id: str
    6. passed: bool
    7. steps: int
    8. failure_stage: str = "" # e.g., planning / tool_call / verification
    9. notes: List[str] = field(default_factory=list)
    10. def run_task(task_id: str,
    11. agent: Callable[[str], str],
    12. sandbox_factory: Callable[[str], object],
    13. checker: Callable[[object], bool],
    14. max_steps: int = 50) -> TaskResult:
    15. """Run a single task in an isolated sandbox and return a structured result."""
    16. sandbox = sandbox_factory(task_id) # fresh environment for each task
    17. steps = 0
    18. try:
    19. while steps < max_steps:
    20. action = agent(sandbox.observe())
    21. steps += 1
    22. if sandbox.apply(action) == "done":
    23. break
    24. passed = checker(sandbox) # script-based pass/fail; no human scoring
    25. return TaskResult(task_id, passed, steps)
    26. except Exception as exc:
    27. return TaskResult(task_id, False, steps,
    28. failure_stage="runtime", notes=[str(exc)])
    29. finally:
    30. sandbox.close()
    31. def pass_rate(results: List[TaskResult]) -> float:
    32. if not results:
    33. return 0.0
    34. return sum(r.passed for r in results) / len(results)

    The key points of this skeleton are threefold: each task runs in a fresh environment, completion is determined by scripts, and failure information is saved in a structured way. Only in this way can pass rates across different model versions be comparable.

    3.2 Issues to Consider When Interpreting Pass Rates

    A single pass rate cannot fully describe model capability. The same score may come from different task distributions, different step limits, or different environment configurations. When comparing two models, ensure that evaluation conditions are fully consistent and also examine the distribution of failure types. If two models have similar pass rates but one has noticeably fewer failures during tool calling, it may be more stable in real engineering use.

    4. Trade-Offs Between Standard and Low-Latency Versions

    Many model services provide both standard and low-latency versions. While their target capabilities are consistent, they usually differ in output speed, unit cost, and concurrency capacity. Low-latency versions are better suited to interactive scenarios such as code completion, real-time chat, and agent loops that require fast feedback. Standard versions are better suited to batch processing, offline analysis, and cost-sensitive tasks.

    When selecting a version, consider the following steps:

    1. Build a test set from real tasks in your own business rather than relying only on public leaderboards.
    2. Record first-token latency, total generation time, per-task cost, and final task success rate for both versions.
    3. Calculate “successful tasks per unit cost” as a composite decision metric.
    4. Roll out a canary switch in a low-traffic environment and observe online error rates and user feedback.

    5. Using Long-Context Capabilities Appropriately

    Support for very long contexts allows a model to read more material at once, such as a complete code repository, a long document, or multiple rounds of history. However, a larger context window does not mean that all content will be used effectively. In practice, three issues require attention.

    • Information position effects: A model’s sensitivity to information at different positions in the context may vary. Key constraints should be explicitly repeated in the prompt or placed in a prominent position.
    • Cost and latency: Longer inputs usually lead to higher inference time and cost. Only content relevant to the task should be retained.
    • Retrieval and chunking: For materials that exceed the budget, a retrieval or summarization module can first filter them before passing them to the model.

    6. A Practical Checklist for Developers

    To translate the above ideas into engineering practice, the following checklist can be used.

    • Build a task set: Divide task types by business scenario, retain a sufficient sample size for each type, and update the set regularly.
    • Freeze the evaluation environment: Sandbox images, dependency versions, and resource quotas should be version-managed to ensure reproducible results.
    • Record complete traces: Save the input, output, and tool call results of each step for later review.
    • Measure cost per successful task: Dividing compute or cost by the number of successful tasks reflects real efficiency better than looking only at average scores.
    • Isolation and permission control: Agent commands should run in isolated environments with least privilege. Credentials should be injected through environment variables or a secret management service and should not be written into code or logs.
    • Set up rollback mechanisms: Before a model upgrade, keep the old version as a baseline so that a quick switch is possible if quality degrades.

    7. Conclusion

    Capability improvement in large models is shifting from simply scaling up to post-training and engineering iteration centered on reinforcement learning. For developers, understanding compute conversion efficiency, mastering evaluation methods for long-horizon tasks, and making rational trade-offs between versions based on business scenarios are more valuable than chasing a single leaderboard score. Building an evaluation system that is reproducible, attributable, and measurable is the foundation for reliably bringing model capabilities into production.