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

“Self-hosted agent” can mean very different architectures. This guide separates the managed harness, self-hosted execution environment, and fully self-operated agent loop—and shows which control boundary teams actually need.
Published:
Aleksandar Stajić
Updated: September 25, 2026 at 09:49 PM
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”

ArchitectureWho runs the harness?Where code/files executeWhat you primarily own
Managed harness + managed environmentPlatformPlatform-hosted sandboxApplication, tools, product logic, authorization
Managed harness + self-hosted environmentPlatformYour container, VM, laptop, private cloud or other computeEnvironment provisioning, networking, files and lifecycle; platform still owns harness
Self-operated harness / agent loopYouYour chosen environmentHarness process, orchestration, context strategy, hosting, recovery, execution and application lifecycle

The two-plane model

Separate the harness plane from the execution plane

PlaneWhat it ownsQuestions 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-offWhat it means operationally
Less loop controlYou cannot assume every orchestration detail is application-defined
Platform evolutionHarness behaviour can improve or change without your code changing
Vendor-specific lifecycleSessions, events and recovery semantics become part of the integration surface
Observability boundaryPlatform traces must be joined with application audit data
Portability costMoving 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.

RequirementExecution-plane problem or harness-plane problem?Likely direction
Private database accessExecution planeManaged harness + self-hosted environment may be sufficient
Custom Linux packagesExecution planeManaged harness + self-hosted environment
Custom GPU hardwareExecution planeManaged harness + self-hosted environment where supported
Custom agent stopping logicHarness planeSelf-operated harness / custom loop
Cross-provider model routing at every stepHarness planeCustom loop or harness you operate
Custom context-compaction algorithmHarness planeSelf-operated harness if the managed runtime cannot expose it
Deterministic orchestration semantics required by productHarness planeSelf-operated harness or tightly controlled custom loop
Local-only product deployment with no managed harness dependencyHarness plane + execution planeSelf-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

1
1. Start with the application boundary
Keep domain truth, authorization and consequential business actions in your own product regardless of agent runtime.
2
2. Ask whether the agent needs local execution
If not, a managed harness without a dedicated environment may be enough.
3
3. Ask whether platform-hosted compute is acceptable
If yes, use a managed environment and avoid unnecessary infrastructure ownership.
4
4. If not, self-host the execution plane
Connect your own environment for private network, files, packages or controlled compute.
5
5. Re-evaluate the remaining constraint
If the requirement is now satisfied, stop. Do not self-host the harness simply for architectural symmetry.
6
6. Escalate to harness ownership only for harness requirements
Own the Codex harness or custom agent loop when orchestration, context strategy, lifecycle or portability genuinely requires it.
7
7. Prove the extra control is worth the extra operations
Benchmark reliability, latency, cost, recovery, observability and engineering burden before committing.

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 forWhy it matters
Durable session stateProcesses restart; long-running work must resume correctly
Context compactionHistory eventually exceeds practical working context
Tool idempotencyRetries must not repeat irreversible side effects
Cancellation and interruptionUsers and systems need to stop or redirect work
Recovery after partial executionA tool may succeed even if the agent never receives the result
ConcurrencyMultiple tasks, workers or agents can touch shared state
ObservabilityFinal output is insufficient for debugging runtime failures
VersioningHarness updates can change behaviour even when prompts remain constant
EvaluationRuntime 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

ConstraintManaged harness + managed environmentManaged harness + self-hosted environmentSelf-operated harness / loop
Fastest path to productionStrongModerateWeakest
Private-network executionWeak / depends on connectivity designStrongStrong
Custom packages / system softwareModerateStrongStrong
Harness-level controlLowLowHighest
Operational burdenLowestMediumHighest
PortabilityLowestMediumPotentially highest if intentionally designed
Context strategy controlPlatform-managedPlatform-managedApplication-controlled
Execution infrastructure controlLowHighHigh
Ability to benefit from managed harness updatesHighestHighestYou own adoption
Best fitTeams differentiating at product/tool layerTeams needing private/custom compute without owning orchestrationTeams 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?

Not completely. OpenAI still runs the managed Codex harness, while your infrastructure runs the execution environment used for commands, files and local tools.

When is a self-hosted environment enough?

It is often enough when your requirements concern private-network access, custom packages, controlled files, specific hardware or infrastructure policy rather than control over the agent loop itself.

When should I run the harness myself?

Consider harness ownership when you need custom orchestration semantics, custom context management, provider routing, local-only runtime behaviour, or another requirement that lives in the agent loop rather than the execution environment.

Does self-hosting automatically improve security?

No. It changes which components you control. Security depends on data flow, isolation, credentials, tool permissions, networking, logging and lifecycle design across all components.

What is the main operational cost of owning the agent loop?

You become responsible for durable state, context management, retries, cancellation, recovery, observability, concurrency, runtime upgrades and evaluation of harness changes.

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 Architecture

Current separation between the hosted harness, execution environment and application server.

OpenAI — Self-hosted sandboxes

How customer-operated execution environments connect to the managed harness and which lifecycle responsibilities remain with the application.

OpenAI — Sandbox lifecycle

Provisioning, reconnection, duplicate-environment prevention and cleanup responsibilities for self-hosted compute.

OpenAI — Agent runtime options

Current comparison of Agents API, Codex SDK and Responses API by managed versus application-operated responsibilities.

OpenAI — Codex as a platform

Open-source Codex harness and integration layers for applications that want deeper runtime control.

Anthropic — Scaling Managed Agents: Decoupling the brain from the hands

Discussion of managed-agent architecture and why harness assumptions need to evolve with model capability.

Anthropic — Effective harnesses for long-running agents

Engineering 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

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

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

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

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

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

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.