Managed Agent Harness vs Self-Hosted Agent Loop: What You Gain, What You Lose

The phrase “self-hosted agent” now hides at least three different architectures. You can use a managed harness with OpenAI-hosted compute, a managed harness connected to infrastructure you operate, or run the harness and agent loop yourself. Those choices have very different implications for control, recovery, context management, security, latency, and operational burden.
The mistake: treating self-hosting as one decision
In conventional software, “self-hosted” usually means the application runs on infrastructure you control. Agent systems complicate that definition because the runtime can be split. The model-and-tool loop can run in one place while code execution, files and private-network access happen somewhere else.
OpenAI's current Agents API architecture makes this split explicit: OpenAI runs the harness, while the execution environment can be absent, OpenAI-hosted, or self-hosted. A self-hosted environment therefore does not mean the agent loop is self-hosted.
This distinction matters because many teams choose a more complex runtime than they need. They want private-network access or custom packages, conclude that the entire agent must be self-hosted, and accidentally take ownership of context management, orchestration, recovery and lifecycle that could have remained managed.
Three architectures that are often called “self-hosted”
| Architecture | Who runs the harness? | Where code/files execute | What you primarily own |
|---|---|---|---|
| Managed harness + managed environment | Platform | Platform-hosted sandbox | Application, tools, product logic, authorization |
| Managed harness + self-hosted environment | Platform | Your container, VM, laptop, private cloud or other compute | Environment provisioning, networking, files and lifecycle; platform still owns harness |
| Self-operated harness / agent loop | You | Your chosen environment | Harness process, orchestration, context strategy, hosting, recovery, execution and application lifecycle |
The two-plane model
Separate the harness plane from the execution plane
| Plane | What it owns | Questions to ask | |
|---|---|---|---|
| Harness plane | |||
| Execution plane | |||
| Application plane |
Managed harness: what you actually gain
A managed harness removes more than a while-loop. OpenAI's current Agents API manages sessions, orchestration, context compaction and recovery. Anthropic's work on managed agents describes the same broader motivation: harnesses contain assumptions about model behaviour, and those assumptions need to evolve as models improve.
That means the benefit is not only fewer lines of code. The platform can update runtime behaviour, long-horizon context handling, subagent coordination and recovery without requiring every application team to rebuild those mechanisms.
- Less application-owned orchestration code.
- Managed durable-session behaviour.
- Managed context compaction and recovery.
- A runtime that can evolve with model capabilities.
- Simpler adoption of platform-native subagent and long-running-agent features.
- Potentially lower operational burden for teams whose differentiation is not the harness itself.
Managed harness: what you give up
Delegating the harness also delegates some control. Your application no longer owns every detail of iteration, context strategy, orchestration and runtime evolution. A platform update can improve the system, but it can also change behaviour your product implicitly depended on.
This creates a different kind of engineering requirement: strong evals, explicit product boundaries and an integration layer that prevents managed-session behaviour from becoming your business source of truth.
| Managed-harness trade-off | What it means operationally |
|---|---|
| Less loop control | You cannot assume every orchestration detail is application-defined |
| Platform evolution | Harness behaviour can improve or change without your code changing |
| Vendor-specific lifecycle | Sessions, events and recovery semantics become part of the integration surface |
| Observability boundary | Platform traces must be joined with application audit data |
| Portability cost | Moving to another harness later may require more than swapping model endpoints |
Self-hosted execution environment: the middle architecture
OpenAI's self-hosted environment model is important because it decouples private compute from harness ownership. The platform still runs the Codex harness, while an executor runs inside your environment and receives commands over an outbound connection.
You control provisioning, files, dependencies, network access and cleanup. The harness can therefore work against private infrastructure or custom software without requiring the entire agent runtime to move into your application.
The cost is lifecycle responsibility. Your application must map sessions to compute, avoid duplicate provisioning, reconnect environments, coordinate shutdown and preserve any files that must outlive the environment.
When self-hosted execution is enough
- The agent needs access to a private VPC or internal service.
- The agent needs custom binaries, packages, drivers or system software.
- The workload must run on hardware or cloud accounts you control.
- Files must remain inside a controlled environment.
- You need your own sandbox provider or isolation model.
- You want platform-managed orchestration but infrastructure-controlled execution.
When you may need to own the harness too
Owning the harness becomes justified when the harness itself is part of your product differentiation or constraint set. OpenAI's current runtime overview positions the Codex SDK for running the Codex harness in infrastructure you operate, while Responses is the lower-level option when you want to own the agent loop yourself.
The key is to identify a requirement that genuinely lives in the harness plane, not the execution plane.
| Requirement | Execution-plane problem or harness-plane problem? | Likely direction |
|---|---|---|
| Private database access | Execution plane | Managed harness + self-hosted environment may be sufficient |
| Custom Linux packages | Execution plane | Managed harness + self-hosted environment |
| Custom GPU hardware | Execution plane | Managed harness + self-hosted environment where supported |
| Custom agent stopping logic | Harness plane | Self-operated harness / custom loop |
| Cross-provider model routing at every step | Harness plane | Custom loop or harness you operate |
| Custom context-compaction algorithm | Harness plane | Self-operated harness if the managed runtime cannot expose it |
| Deterministic orchestration semantics required by product | Harness plane | Self-operated harness or tightly controlled custom loop |
| Local-only product deployment with no managed harness dependency | Harness plane + execution plane | Self-operated runtime |
The Control Escalation Test
Use the least self-hosted architecture that satisfies the actual requirement. Escalate control one layer at a time.
Control Escalation Test
Operational burden grows nonlinearly when you own the harness
A self-operated loop sounds simple in a demo: call model, inspect tool call, execute tool, append result, repeat. Production adds durable state, retries, duplicate events, cancellation, approval, context overflow, tool timeouts, process restarts, trace persistence, backpressure, concurrent work and recovery after partial side effects.
Long-running-agent research from Anthropic repeatedly shows that harness design materially affects performance. Their work on long-running application development uses explicit planning, structured artifacts and evaluator agents because naïve loops tend to lose progress or terminate prematurely. The harness is therefore production logic, not plumbing.
| If you own the harness, you also need an answer for | Why it matters |
|---|---|
| Durable session state | Processes restart; long-running work must resume correctly |
| Context compaction | History eventually exceeds practical working context |
| Tool idempotency | Retries must not repeat irreversible side effects |
| Cancellation and interruption | Users and systems need to stop or redirect work |
| Recovery after partial execution | A tool may succeed even if the agent never receives the result |
| Concurrency | Multiple tasks, workers or agents can touch shared state |
| Observability | Final output is insufficient for debugging runtime failures |
| Versioning | Harness updates can change behaviour even when prompts remain constant |
| Evaluation | Runtime changes need regression testing across representative trajectories |
Security boundary: self-hosting compute does not automatically make the agent private
A self-hosted execution environment controls where commands run and where files live, but the managed harness and model interaction still cross the service boundary. Teams should therefore map data flows explicitly rather than use “self-hosted” as shorthand for a privacy property.
OpenAI's self-hosted executor uses restricted environment credentials and outbound connections. That is useful isolation, but your application still needs its own rules for secrets, private-network exposure, user-to-environment isolation, file retention, tool authorization and data classification.
Latency and cost: control can move bottlenecks rather than remove them
Self-hosting may reduce some data-path or environment-startup costs, but it can also add provisioning time, WebSocket lifecycle, cold starts, sandbox cleanup, observability infrastructure and engineering overhead. A managed environment may cost more per unit of compute while being cheaper to operate at low or irregular volume.
The correct comparison is total system cost: model and tool usage, environment time, infrastructure, engineering effort, on-call burden, failure recovery and the cost of slower iteration.
A production decision matrix
| Constraint | Managed harness + managed environment | Managed harness + self-hosted environment | Self-operated harness / loop |
|---|---|---|---|
| Fastest path to production | Strong | Moderate | Weakest |
| Private-network execution | Weak / depends on connectivity design | Strong | Strong |
| Custom packages / system software | Moderate | Strong | Strong |
| Harness-level control | Low | Low | Highest |
| Operational burden | Lowest | Medium | Highest |
| Portability | Lowest | Medium | Potentially highest if intentionally designed |
| Context strategy control | Platform-managed | Platform-managed | Application-controlled |
| Execution infrastructure control | Low | High | High |
| Ability to benefit from managed harness updates | Highest | Highest | You own adoption |
| Best fit | Teams differentiating at product/tool layer | Teams needing private/custom compute without owning orchestration | Teams whose runtime semantics are themselves a requirement |
Hybrid is not a compromise — it is often the clean architecture
A managed harness with self-hosted execution is not “half self-hosted.” It is an intentional separation of concerns. The platform owns long-horizon agent-runtime complexity, while your infrastructure owns execution, private connectivity and files.
That boundary resembles other cloud architectures: managed control plane, customer-controlled data or execution plane. The important design work is defining the contract between them — session identity, environment identity, credentials, files, tool permissions, lifecycle events and cleanup.
What would change this answer?
The recommendation changes if managed harnesses expose substantially more runtime control, if self-hosted harnesses gain simpler durable-session and recovery primitives, or if regulation requires the entire agent loop and model interaction to remain inside infrastructure you operate.
It also changes with model capability. Anthropic explicitly notes that harness assumptions can become stale as models improve. A control mechanism that is essential today may become unnecessary later, while a new model capability can create a new governance requirement.
Limitations
This article separates architecture responsibilities; it does not claim that one hosting model is universally more secure, cheaper or more reliable. Those outcomes depend on implementation, workload, compliance requirements, team skill and provider behaviour.
The OpenAI Agents API is still in public beta, and managed-agent products from different vendors expose different boundaries. The two-plane model is intended to help compare those architectures without assuming that every vendor uses identical terms.
Conclusion
The useful question is not “Should we self-host the agent?” It is: Which plane do we actually need to control?
If the requirement is private compute, custom packages, local files or internal-network access, self-host the execution plane and keep the harness managed. If the requirement is orchestration semantics, context strategy, provider control or runtime lifecycle itself, then harness ownership may be justified. Escalate control only as far as the requirement demands.
FAQ
Managed harnesses and self-hosted agent runtimes
Is an OpenAI Agents API self-hosted environment a self-hosted agent?
When is a self-hosted environment enough?
When should I run the harness myself?
Does self-hosting automatically improve security?
What is the main operational cost of owning the agent loop?
Glossary
Key architecture terms
- Harness plane
- The agent-runtime layer responsible for loop execution, orchestration, context management, session continuity and recovery.
- Execution plane
- The environment in which commands run, code executes and files, packages and local resources are accessed.
- Managed harness
- An agent harness whose runtime, session management and orchestration are operated by a platform provider.
- Self-hosted environment
- Compute and files operated by the application owner while a separate agent harness may remain managed elsewhere.
- Self-operated harness
- An agent runtime whose loop, hosting, context strategy and lifecycle are operated by the application team.
- Control Escalation Test
- A decision method that increases infrastructure and runtime ownership only when a requirement cannot be satisfied at a lower-control layer.
Primary sources and further reading
OpenAI — Agents API ArchitectureCurrent separation between the hosted harness, execution environment and application server.
OpenAI — Self-hosted sandboxesHow customer-operated execution environments connect to the managed harness and which lifecycle responsibilities remain with the application.
OpenAI — Sandbox lifecycleProvisioning, reconnection, duplicate-environment prevention and cleanup responsibilities for self-hosted compute.
OpenAI — Agent runtime optionsCurrent comparison of Agents API, Codex SDK and Responses API by managed versus application-operated responsibilities.
OpenAI — Codex as a platformOpen-source Codex harness and integration layers for applications that want deeper runtime control.
Anthropic — Scaling Managed Agents: Decoupling the brain from the handsDiscussion of managed-agent architecture and why harness assumptions need to evolve with model capability.
Anthropic — Effective harnesses for long-running agentsEngineering lessons showing that long-running agent performance depends materially on harness design and persistent artifacts.
Related Articles

RAG Failed — But Which Layer Actually Failed? A Diagnostic Method
When a RAG answer is wrong, blaming retrieval or the model is too vague. This diagnostic method isolates source coverage, query construction, retrieval, ranking, context assembly, generation, evidence attribution, and freshness—so the actual failure can be reproduced and fixed.

Mastering the SEO Workflow: Essential Optimization Strategies for Organic Growth
A structured SEO workflow is crucial for sustainable organic growth. Learn the ten foundational strategies, from keyword research and technical optimization to content quality and performance analysis.

Comprehensive Guide to Evaluation Harness: Mastering LLM Performance Evaluation
This guide provides a detailed walkthrough of Evaluation Harness, an essential framework for rigorously assessing large language model (LLM) capabilities in enterprise LLMOps pipelines. Learn setup, best practices, and advanced techniques to ensure reliable model benchmarking and optimization.

ZBT Z8102AX Dual-SIM Failover: What Works, What Is Missing and What Needs Better Firmware
The ZBT Z8102AX is a dual-SIM 5G OpenWrt router, but dual-SIM hardware alone is not the same as intelligent failover. The router recognizes the SIM and connects successfully, but automatic switching, modem recovery, signal-based decisions and clean failover logic still need deeper testing.

Ollama Is Not the Product: Building Production-Ready Open-LLM Applications
Running a local model with Ollama is easy. Building a production-ready Open-LLM application is harder: it requires RAG, access control, provider abstraction, evaluation, logging, deployment discipline and a controlled application layer around the model.

Search Engine Optimization: The reliable workflow for Top-Rankings
Detailed analysis of search engine optimization (SEO), its technical foundations, the role of web crawlers, and the strategic steps to achieve organic top rankings.