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:
- 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.
- 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.
- 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.
class AgentSandboxManager:def __init__(self, container_client, audit_logger):self.client = container_clientself.audit = audit_loggerdef launch_sandbox(self, agent_id, task_config):sandbox_config = {"image": task_config["env_image"], # Use a fixed version tag, not latest"cpu_limit": task_config.get("cpu", "2"),"memory_limit": task_config.get("memory", "4Gi"),"network_policy": "egress_deny_all", # Deny external network by default; add allowlisted addresses as needed"run_as_user": "1000", # Run as non-root"max_ttl_seconds": 4 * 3600, # Force reclamation after timeout}sandbox = self.client.create_instance(sandbox_config)self.audit.record(agent_id=agent_id, sandbox_id=sandbox.id, event="created")return sandbox.iddef reclaim(self, sandbox_id):# Stop the instance, delete volumes and temporary credentials, and record the reclamation resultself.client.delete_instance(sandbox_id)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:
- Run small-scale tests on target tasks and record success rate, latency, and cost.
- Verify that sandbox reclamation and credential rotation processes can execute normally.
- 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.
