AI agents · OpenClaw · self-hosting · automation

Quick Answer

What Is the OpenAI Agents API? Codex Harness Explained

Published:

The Short Answer

On September 10, 2026, OpenAI released the Agents API in public beta: a hosted version of the Codex harness that runs long-lived agent sessions for you. You describe the agent (model, instructions, tools, MCP servers), choose where it runs (OpenAI-hosted sandbox, your own infrastructure, or a partner sandbox), and send it tasks. OpenAI handles orchestration, context compaction, subagent delegation, steering and recovery. There is no surcharge — you pay token, tool and container rates.

Detail (as of September 11, 2026)
StatusPublic beta, all developers, no GA date
EndpointPOST /v1/agents/sessions with header OpenAI-Beta: agents=v1; SDK call client.beta.agents.sessions.create(...)
HarnessSame open-source Codex harness that powers Codex and ChatGPT Work (github.com/openai/codex)
EnvironmentsOpenAI-hosted sandbox · self-hosted (type: "self_hosted") · partner sandboxes: Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, Vercel
Built inContext compaction, tool search, programmatic tool calling, multi-agent (max_concurrent_subagents), MCP, web search, skills, artifacts, webhooks/streaming
PricingModel tokens at API rates + built-in tools at standard rates + OpenAI sandboxes at standard container rates. No Agents API fee.
Data controlsUS data residency only; no Zero Data Retention, even with a self-hosted sandbox

What you actually get

OpenAI’s framing: after scaling Codex and ChatGPT Work to millions of users, the hard part of agents turned out to be the harness — context management, efficient tool use, subagent coordination — plus infrastructure that keeps an agent running for days with files, code execution and intermediate results. The Agents API packages both.

The four core concepts in the docs:

  • Agent — the model, instructions, tools and MCP servers.
  • Environment — an optional sandbox or computer where the agent reads files, loads skills and runs commands.
  • Session — a durable instance of the agent that works on tasks and accepts more input.
  • Events and items — what you send in and what comes out, via streaming or webhooks.

A session’s lifecycle is: create (OpenAI provisions the environment) → give it a task → follow progress by stream or webhook → send another task to the same session, or steer it mid-turn.

The harness features that matter

Compaction. As a session approaches the model’s context limit, the API automatically summarises earlier context while preserving what the agent needs to continue. Workflows can span multiple context windows without you writing compaction logic.

Tool search + programmatic tool calling. Tool definitions are loaded on demand to save tokens and preserve the prompt cache. Once tools are available, the agent can call them in parallel, chain them and filter results in code, bringing only the relevant slice back into context — the same trick that makes Codex efficient on large datasets.

Subagents. With multi_agent: { enabled: true, max_concurrent_subagents: N }, the main agent splits work and delegates to subagents that each keep their own context, then merges results. OpenAI’s example is comparing release notes in parallel.

Steering and resuming. You can redirect an agent during a turn and pick a session back up where it left off.

Where the agent runs

This is the design decision OpenAI made differently from most competitors: the harness is hosted, but the compute is your choice.

  • OpenAI-hosted sandbox — the same sandboxing infrastructure behind Codex and ChatGPT, provisioned and managed by OpenAI, configurable with your files, packages, skills and plugins. Billed at container rates.
  • Self-hosted — the agent’s commands run on your infrastructure (workspace_directory, capability_directories), inside your VPC and network policy.
  • Partner sandboxes — first-class integrations with Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop and Vercel, covering managed environments, VPC deployments, specific secret/file storage, and different CPU/GPU/memory and cold-start profiles.

Note the fine print: self-hosting the sandbox keeps your files home, but the session state, transcripts and orchestration still live with OpenAI in the US, and the endpoint is not ZDR-eligible. Regulated teams that need ZDR should stay on the Responses API with their own loop for now.

How it compares (September 2026)

OpenAI Agents APIOpenAI Agents SDKAnthropic Managed Agents / Claude Agent SDK
Who runs the loopOpenAI (hosted Codex harness)You, in-process (open-source library)Anthropic (Managed Agents) or you (Agent SDK)
SandboxOpenAI-hosted, self-hosted or 9 partnersWhatever you wire upAnthropic-managed cloud sandbox or self-hosted sandbox (GA on Claude API since mid-2026)
Extra feeNone — tokens + tools + containersNoneManaged Agents bill session-hours plus tokens
ZDRNoDepends on the model endpoint you callDepends on plan/endpoint
Harness sourceOpen (github.com/openai/codex)OpenAgent SDK open; managed control plane closed

The closest analogue is Anthropic’s Managed Agents plus the Claude Agent SDK: both vendors now sell “our production harness, your tools, your choice of sandbox.” The difference in September 2026 is pricing shape — OpenAI charges nothing for the harness itself, Anthropic meters session-hours — and OpenAI’s explicit ZDR gap.

Who should use it

  • Yes: teams building long-running cloud agents (incident responders, GitHub issue investigators, data analysts over a warehouse, document reviewers — all of which OpenAI ships as showcase apps) who do not want to maintain compaction, tool routing and subagent orchestration themselves.
  • Yes, carefully: anyone already on the Agents SDK who wants to move heavy sessions off their own servers; sessions, SDK sessions and Responses conversations are separate resources, so this is a migration, not a flag flip.
  • Not yet: ZDR-mandated workloads, non-US data residency, or products that need GA-level stability guarantees.

Sources