Long-Horizon Agents: Training, Infrastructure, and Managed Services

    This article examines how long-horizon agent capabilities depend on reinforcement learning in post-training, sandboxed execution and scheduling infrastructure, and managed agent services. It also provides practical checks for comparing code benchmark results, evaluating service contracts, running production tests, and controlling operational risks.

    Conclusion First

    The capabilities of long-horizon agents mainly come from three areas: reinforcement learning during post-training, sandbox environments that provide isolated execution, and observable scheduling systems. Managed services can reduce the amount of infrastructure work teams need to build themselves, but availability and cost depend on the specific provider’s contract terms and actual test results.

    1. Post-Training: Reinforcement Learning Expands into More Specialized Domains

    Increasing post-training compute is a major current direction. Reinforcement learning is expanding from board games and simple code generation into vertical domains such as programming and financial analysis. In practice, teams usually need to address three things:

    1. Design reward functions for different domains and define what counts as a “good result.” For programming tasks, test pass rates can be used; for analysis tasks, human or rule-based verification methods are needed.
    2. For long-context tasks, evaluate inference cost and information loss. Longer inputs increase compute overhead, and whether key information is omitted also needs to be tested separately.
    3. Optimize communication and gradient synchronization on large-scale clusters. Multi-GPU training efficiency directly affects iteration speed.

    The effectiveness data that teams publish in technical reports is the basis for judging the maturity of these directions. This article does not provide specific domain counts or performance gain figures because verifiable sources are lacking.

    2. Infrastructure: Sandboxes, Scheduling, and Environment Checks

    Long-horizon agents may run continuously for hours, repeatedly executing code and tool calls. Infrastructure must simultaneously meet requirements in three areas: security isolation, resource scheduling, and state consistency.

    1. Sandbox Isolation

    Code and commands generated by agents should run in isolated environments to prevent accidental operations from affecting the host machine or other tasks. Common approaches use containers or lightweight virtualization and meet the following requirements:

    • Limit CPU, memory, and disk quotas;
    • Deny outbound network access by default and allow only allowlisted addresses;
    • Run as a non-root user and restrict mountable paths;
    • Record audit logs of commands and file operations;
    • Set a maximum lifetime, force reclamation after timeout, and clean up residual files and temporary credentials.

    The following code is a conceptual example. In actual use, it needs to be replaced with the selected cloud platform’s interfaces, and dependency versions should be pinned.

    1. class AgentSandboxManager:
    2. def __init__(self, container_client, audit_logger):
    3. self.client = container_client
    4. self.audit = audit_logger
    5. def launch_sandbox(self, agent_id, task_config):
    6. sandbox_config = {
    7. "image": task_config["env_image"], # Use a fixed version tag, not latest
    8. "cpu_limit": task_config.get("cpu", "2"),
    9. "memory_limit": task_config.get("memory", "4Gi"),
    10. "network_policy": "egress_deny_all", # Deny external network by default; add allowlisted addresses as needed
    11. "run_as_user": "1000", # Run as non-root
    12. "max_ttl_seconds": 4 * 3600, # Force reclamation after timeout
    13. }
    14. sandbox = self.client.create_instance(sandbox_config)
    15. self.audit.record(agent_id=agent_id, sandbox_id=sandbox.id, event="created")
    16. return sandbox.id
    17. def reclaim(self, sandbox_id):
    18. # Stop the instance, delete volumes and temporary credentials, and record the reclamation result
    19. self.client.delete_instance(sandbox_id)
    20. self.audit.record(sandbox_id=sandbox_id, event="reclaimed")

    2. Scheduling

    When thousands of agents run simultaneously, the scheduler needs to consider task priority, resource requirements, and cluster load. Scheduling effectiveness can be judged by three metrics: queue time, resource fragmentation rate, and task failure rate. When resources are tight, the scheduler should make new tasks wait or degrade rather than letting all tasks slow down at the same time.

    3. Environment Checks

    During long-running tasks, sandboxes may experience full disks, leaked processes, or accidentally modified dependencies. An environment check platform should check key states before each interaction or at fixed intervals. When drift is detected, the platform should rebuild the environment and record the reason for later troubleshooting.

    3. Code Capabilities: Evaluation Results Depend on Test Conditions

    Code evaluation is gradually moving from function-level and file-level evaluation to terminal-level evaluation. Terminal-level evaluation requires models to complete software engineering tasks through commands in a real operating system, with scores determined by compilation and test results.

    When comparing evaluation scores between two models, the following information should be confirmed first:

    • The name and version of the evaluation benchmark;
    • The runtime environment, timeout settings, and retry count;
    • The scoring method: single-pass rate or average over multiple runs;
    • Whether the two models used the same toolset.

    If only statements such as “close to mainstream closed-source models” are available, the original evaluation data should be found first. Conclusions that lack these conditions are not suitable for direct use in technical selection.

    4. Managed Agent Services: Check the Contract Before Evaluating Capabilities

    Managed agent services provide the frameworks and infrastructure required to run agents as cloud services. Developers define goals and toolsets, and the platform handles execution and scheduling. Multi-agent collaboration is also a common feature, for example, with planning, coding, and testing roles divided among agents. Communication protocols and configuration methods vary significantly across platforms and need to be verified one by one.

    The following table can be used for checks during selection:

    Dimension Questions to confirm
    Availability SLA coverage, failure compensation conditions, maintenance windows
    Isolation Sandbox isolation level, network ingress and egress controls, multi-tenant boundaries
    Observability Whether logs, metrics, and traces can be exported to internal systems
    Recovery Whether tasks can resume from checkpoints, how state is persisted, and failure recovery time
    Permissions Least-privilege model, secret management method, audit record retention period
    Cost Billing dimensions (cached input, uncached input, output), and how long-running tasks are timed
    Data compliance Data storage region, retention period, and whether data is used for model training

    5. Production Checklist and Risk Notes

    Before launch, completing the following three checks is recommended:

    1. Run small-scale tests on target tasks and record success rate, latency, and cost.
    2. Verify that sandbox reclamation and credential rotation processes can execute normally.
    3. Add human confirmation steps for high-risk agent actions, such as deleting files, sending messages, and changing permissions.

    Risk notes:

    • Costs for long-running tasks may exceed expectations, so budget alerts should be configured.
    • When running unattended, agents may make incorrect file modifications, so version snapshots should be retained for rollback.
    • Vendor-reported availability figures should be judged based on contract terms and actual monitoring data.