Back to Blog
Original

OpenAI's Agents API Explained: Cloud Agents on the Managed Codex Harness

OpenAI's Agents API runs the open source Codex harness as a managed cloud service: durable sessions, automatic context compaction, multi-agent orchestration, and optional sandboxes. How the architecture works, what it costs, and when to choose it over the Agents SDK.

13 September 202613 min read
OpenAI's Agents API Explained: Cloud Agents on the Managed Codex Harness

Last Updated: September 13, 2026

OpenAI has put its agent harness in the cloud. The Agents API, announced by OpenAI Developers on September 10, 2026 and available now in public beta, runs the open source Codex harness as a managed service: OpenAI handles orchestration, long-running sessions, and context management while your application supplies the tools and chooses where the agent computes. The bet is blunt. The layer that turns a language model into a dependable worker is becoming infrastructure, and infrastructure should be rented, not rebuilt by every team.

The numbers behind that bet deserve attention. According to OpenAI's developer blog, harness settings alone, retained reasoning plus context compaction, raised GPT-5.6 Sol's ARC-AGI-3 score from 13.3% to 38.3% while cutting output tokens sixfold. In a production pilot, Thrive Holdings and Crete ran tax preparation on the Codex harness and processed 7,000 returns, reducing preparation time by about a third. This guide covers what the Agents API is, how its architecture works, what it costs, and when a growing business should choose it over the Agents SDK or the Responses API.

"We handle orchestration, long-running sessions, and context management. You focus on what makes your agent unique," OpenAI Developers, @OpenAIDevs, September 10, 2026.

What is OpenAI's Agents API?

The Agents API is a managed cloud service that gives your application access to the Codex harness through a single OpenAI endpoint. The harness is the execution system around the model: it gathers context, runs the tool loop, enforces sandbox and approval policies, streams progress, and carries work across turns. The same open source harness already powers the Codex app, CLI, and IDE extension, and OpenAI now runs it for you behind an API. Sessions are created at a single endpoint with a beta header, and the service is built around four concepts: the agent, the environment, the session, and the events and items that flow between you and the work.

According to OpenAI's documentation, OpenAI manages sessions, orchestration, context compaction, and recovery, while your application provides tools and picks the execution environment. Agents can operate in a sandbox where they execute code, edit files, connect to MCP servers, and produce artifacts. The quickstart example is deliberately small: create a session, ask the agent to write a Python script that prints a directory tree, and watch it write the file, run it, and report real output.

How the architecture works: three moving parts

The Agents API splits an agent deployment into three pieces: the harness, the environment, and your application server. The harness is the OpenAI-hosted Codex instance that runs the model and tool loop and maintains the session. The environment is where the agent runs commands and works with files, and it can be a remote sandbox, your laptop, a Docker container, or an AWS Lambda function. Your application server submits tasks, receives events, and handles function tools. According to OpenAI's architecture guide, the harness can even work with no environment at all, which keeps the entry point cheap for tool-only agents.

Agents API architecture diagram showing application server, managed Codex harness, sandbox environment, and tools plus MCP connections
How it works: your application creates sessions, OpenAI's managed harness runs the agent loop, and the sandbox executes code and tool calls.

Progress comes back two ways. Streaming delivers detailed events as the agent works, which suits live interfaces. Webhooks deliver session state changes without holding a stream open, which suits background jobs and serverless handlers. Function tools need a handler in your code that receives each call and returns its result, and if that handler is unavailable the agent can end up waiting, so handler availability is part of your uptime story.

Three ways to give your agent compute

Every session picks one of three environment modes. Setting environment.type to none gives you a pure tool-calling agent: the harness can still call remote MCP servers and your function tools, but built-in shell and file tools are unavailable. Setting it to openai_hosted has OpenAI create and manage a sandbox where the agent runs scripts, edits files, and produces artifacts, with you configuring packages, files, and network access. Setting it to self_hosted connects your own infrastructure through an executor: your code starts the environment, connects it to the session, and owns provisioning, reconnection, and shutdown, which suits private networks and custom software.

Three Agents API environment modes compared: no environment with function tools, OpenAI-hosted sandbox, and self-hosted executor on your compute
How it works: each session chooses no compute, OpenAI-managed compute, or your own compute behind an executor connection.

According to OpenAI's quickstart, two security rules matter from day one. Keep your API key outside the agent's sandbox, and create the key with the narrow scopes the API needs: api.agents.read, api.agents.write, and api.responses.write. Provider guides already exist for running environments on platforms like Blaxel and Cloudflare, where webhooks start and reconnect sandbox containers on demand.

What the managed harness handles: sessions, compaction, subagents

The harness is the product. A session is durable: it saves configuration, turns, and items, so you can continue work across turns without rebuilding conversation context, steer the agent mid-turn while it works, and resume where a session left off after a disconnect. According to OpenAI's documentation, the managed harness also applies relevant skills and instructions, breaks work into subtasks, and delegates to subagents, with the docs example allowing up to 4 concurrent subagents. If a stream drops early, you retrieve the session and its saved items rather than starting over.

Durable agent session lifecycle diagram: create session, send task, agent works, stream events, steer mid turn, resume from saved state
How it works: sessions persist turns and items so agents resume where they left off instead of rebuilding context.

Context management is the quiet headline. Long tasks blow context windows, and naive truncation throws away the reasoning that made earlier work good. According to OpenAI's developer blog, "harness design can materially change results": on ARC-AGI-3, retained reasoning and context compaction raised GPT-5.6 Sol's score from 13.3% to 38.3% while reducing output tokens sixfold. The same compaction machinery now runs server-side for every Agents API session, and subagents get their own context windows so parallel research does not crowd out the main thread.

Context compaction loop with subagents keeping isolated windows, ending in the ARC-AGI-3 score jump from 13.3 percent to 38.3 percent
How it works: the harness compacts context automatically, keeps retained reasoning, and isolates subagent work from the main window.

Agents API vs Agents SDK vs Responses API: which should you use?

OpenAI now sells three layers of the same stack, and the choice is about how much of the agent operation you want to own. According to OpenAI's runtime comparison, the Agents API is for long-running tasks where OpenAI manages the agent and saves its progress, with low integration effort. The Agents SDK runs inside your application and gives you control over the agent loop, deployment, storage, and approvals, at medium effort. The Responses API is for calling models directly or building an agent from scratch, at high effort. The table below condenses OpenAI's own comparison.

DimensionAgents APIAgents SDKResponses API
Best forLong-running tasks, OpenAI manages the agentCustom tools and workflows you controlDirect model calls, build from scratch
Where the agent runsManaged Codex harness on OpenAIInside your applicationYour application, optional hosted orchestration
Integration effortLowMediumHigh
State between tasksSaved sessions, turns, and itemsYour storage and SDK sessionsManual history or Conversations
Execution environmentOpenAI sandbox, self-hosted, or noneYour runtime and sandbox providersYour own environment
Control spectrum from Responses API where you build the loop, to Agents SDK where you run it, to Agents API where OpenAI runs it
How it works: each layer up the chain trades control for managed operations, ending with OpenAI running the whole loop.

How much does the Agents API cost?

There is no separate line item for the harness. According to OpenAI's documentation, model usage is billed at the selected model's API rates, OpenAI tools such as web search use their standard rates, and OpenAI-hosted sandboxes bill at standard container rates. You can delete sessions and published artifacts when you no longer need them, which keeps idle costs controllable. The practical read: you pay for the model, the tools, and the compute the agent consumes, and OpenAI absorbs the orchestration plumbing as part of the platform.

Beta caveats matter for planning. According to OpenAI's documentation, the Agents API currently supports data residency only in the United States and does not support Zero Data Retention, and choosing a self-hosted sandbox does not change that. Requests carry an OpenAI-Beta: agents=v1 header, which signals where the contract sits on the stability curve. Australian and European teams with data residency obligations should treat the current beta as a development target, not a compliance answer.

Who is already building on the Codex harness?

The harness already has production runs behind it, and the Apps story is broader than coding. According to GitHub's changelog, GitHub and JetBrains shipped Codex as an agent provider inside their IDEs on July 7, 2026. Cisco uses the Codex SDK in App Builder inside Cisco Cloud Control to take ideas to live apps. Thrive Holdings and Crete run tax preparation on the harness: their pilot processed 7,000 returns and cut preparation time by about a third, with practitioner feedback folded back into the agents. OpenAI's own showcase for the Agents API lists five reference apps, including an incident response agent that investigates alerts and requests approval for recovery actions, a Slack bot, a read-only SQL data analyst, a GitHub issue investigator, and a document reviewer.

Timeline infographic of the Codex harness from the 2025 open source release to the September 2026 Agents API public beta
At a glance: the Codex harness went from open source CLI to a fully managed cloud API in about a year, with GitHub, JetBrains, and Cisco adopting it along the way.

What the Agents API means for growing businesses

The strategic signal is commoditization. When OpenAI rents out the harness that powers Codex, the agent loop, session management, and compaction stop being differentiators and start being table stakes, the same way managed databases made self-run Postgres a choice rather than a necessity. What stays proprietary is everything OpenAI's tweet says to focus on: your tools, your data connections, your approval boundaries, and the interface your team actually works in. For a growing business, the build-versus-buy math shifts toward buying the harness and investing the savings in workflow-specific depth, which is exactly where consultants earn their keep.

We ran the obvious test on ourselves. This article was researched, drafted, diagrammed, and published by Flowbee, our resident agent running on an open source harness stack, in one long-running session that used skills, subagent research, and context compaction to carry a multi-hour workload. The gap between our self-run stack and the managed Agents API is operational, not conceptual, and that is the point: we spent engineering on the parts customers notice, and OpenAI just made that trade available to everyone. For a deeper look at why the harness layer decides agent outcomes, see our earlier analysis of Meta's Auto-RecSys harness engineering work, and for what a fully self-hosted agent stack costs to run, our dual DGX Spark build.

How to start building with the Agents API

Getting from zero to a working cloud agent takes about thirty minutes and five steps, and the quickstart proves the loop end to end by having the agent write and execute a real script.

  1. Create an application API key in your OpenAI platform project with api.agents.read, api.agents.write, and api.responses.write scopes, and keep it outside the sandbox.
  2. Install the OpenAI SDK for Python, JavaScript, Go, Java, or Ruby. The SDK adds the required OpenAI-Beta: agents=v1 header automatically.
  3. Create a session with your model, instructions, tools, and environment type. Start with openai_hosted to let OpenAI manage the sandbox.
  4. Send a task and follow events. Stream events as the agent works, and check for agent.session.turn.completed. Treat turn.failed, turn.cancelled, and session.failed as failures, since an idle session alone does not mean success.
  5. Continue, steer, or resume. Send more input to the same session, steer mid-turn, or retrieve saved items to recover a dropped stream.

The verdict: the Agents API is the fastest legitimate path from idea to a working cloud agent on OpenAI models, and the public beta is the right time to prototype against it. Hold production workloads to the residency rules, and put your effort where the differentiation actually lives: the tools, the data, and the approvals around the agent. That is the work we do at Flowtivity, and the harness layer just got one very large vendor cheaper.

Want AI insights for your business?

Get a free AI readiness scan and discover automation opportunities specific to your business.