Hosted Agent Harness vs DIY Agent Loop: Which Wins in 2026
The Short Answer
| Hosted harness (OpenAI Agents API, Anthropic Managed Agents) | DIY loop (Agents SDK, Claude Agent SDK, LangGraph, Mastra, hand-rolled) | |
|---|---|---|
| Who runs the loop | Vendor | You |
| Compaction, tool search, subagents, resume | Included, updated with each model release | You build and maintain |
| Sandbox | Vendor-hosted, self-hosted or partner | Whatever you wire |
| Time to first working agent | Hours | Days to weeks |
| Platform fee | OpenAI: none; Anthropic: session-hours | None; your compute |
| ZDR / residency | Limited (OpenAI: US-only, no ZDR as of Sep 2026) | Whatever the model endpoint allows |
| Multi-vendor models | Single vendor | Yes |
| Portability | Agent definition yes; sessions/state no | High |
| Debuggability | Events, traces, open-source harness code (OpenAI) | Full |
| Best for | Long-running cloud agents, small teams, fast iteration | Regulated data, multi-model, high-volume cost tuning, unusual loops |
Rule of thumb: start hosted unless compliance or multi-vendor requirements forbid it; go DIY when you can name the specific thing the hosted harness cannot do.
What a harness actually does
The model is a function from context to text. Everything that makes it an agent is harness:
- The loop — call model, parse tool calls, execute, append results, repeat, decide when done.
- Context management — summarise or compact as the window fills, keep instructions pinned, preserve the prompt cache.
- Tool routing — expose the right tools without bloating the prompt; run calls in parallel; filter large results before they hit context.
- Subagents — split work, give each its own context, merge results.
- Persistence — durable sessions you can steer mid-turn and resume days later.
- Environment — a sandbox with files, packages, skills and network policy.
In 2024 every team wrote all of this. By 2026 the frontier labs had written it several times over for their own products and started renting it out.
The hosted option in 2026
OpenAI Agents API (public beta, September 10, 2026): the Codex harness as a service. One session-create call with model, instructions, tools, MCP servers, multi_agent settings and an environment; OpenAI handles compaction, tool search, programmatic tool calling, subagents, steering, resume and webhooks. Compute is your choice — OpenAI-hosted sandbox, self-hosted, or partners (Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, Vercel). No fee beyond tokens, tools and containers. Constraints: US data residency only, no ZDR.
Anthropic Managed Agents plus the Claude Agent SDK: Anthropic runs the control plane and can host the sandbox, or you self-host the sandbox on your infrastructure (GA across the Claude API in mid-2026); billed as session-hours plus tokens. The SDK itself — subagents, compaction hooks, permissions, MCP — is the harness behind Claude Code and is open for DIY use.
Both give you the harness the vendor uses internally, which is the strongest argument for them: the harness is tuned to the model, and it improves the day a new model ships instead of the quarter after.
The DIY option in 2026
DIY no longer means writing the loop from scratch. The realistic stack is an SDK or framework — OpenAI Agents SDK, Claude Agent SDK, LangGraph, Mastra, Microsoft Agent Framework — plus a sandbox provider and your own persistence. You own:
- the execution path (nothing runs where you did not deploy it),
- the model choice (swap vendors, route by task, run open weights locally),
- the data controls (ZDR endpoints, regional residency, your own logs),
- the economics (tune tokens per task, cache aggressively, batch where possible).
You also own the maintenance. Each model generation changes what “good compaction” and “good tool routing” look like; the vendor’s harness moves with the model, yours does not until you move it.
Cost, honestly
Token spend for the same work on the same model is identical either way. The deltas:
- Hosted may use fewer tokens via on-demand tool loading and code-side result filtering. Measure on your workload.
- Hosted adds container or session-hour charges; DIY adds your compute and a person.
- Engineering time dominates below scale. A senior engineer maintaining a bespoke harness costs more than most teams’ inference bills. Above scale — millions of tasks a month — a few percent of tokens is worth that engineer.
Decision guide
| Situation | Pick |
|---|---|
| ZDR contract, EU/UK residency, audited execution path | DIY loop on a compliant endpoint |
| Need to route tasks across OpenAI, Anthropic, Google and open models | DIY |
| Team of 1–5 shipping a cloud agent this month | Hosted |
| Multi-hour research/coding agents with subagents | Hosted (harness is the product) |
| Tightly scripted, low-token, very high volume | DIY, tuned |
| You already run a working SDK loop | Stay; hosted is a migration, not a flag |
| Unusual control flow (human-in-loop at odd points, custom planners) | DIY (or hosted only if steering hooks cover it) |
Reducing lock-in either way
- Put every tool behind an MCP server you control — it moves between harnesses unchanged.
- Keep the sandbox neutral (self-hosted or a provider both vendors integrate with).
- Maintain a vendor-agnostic eval set so a switch is a measurement, not a leap.
- Export artifacts on completion; do not treat vendor session state as your system of record.