Codex harness goes managed in the new Agents API

On September 10, OpenAI made the Codex harness, the agent loop behind Codex, available as a managed service called the Agents API. OpenAI handles sessions, orchestration, context compaction and recovery. Your application supplies the tools and chooses where the agent runs, according to OpenAI’s announcement and its documentation.
The API is built on four concepts. An agent is the model, its instructions, its tools and its MCP servers. An environment is optional: a sandbox or computer where the agent reads files, loads skills and runs commands. A session is a durable instance of an agent that takes tasks and responds to input. Events and items are the inputs you send and the output the session produces.
A session runs in that order. You create a session and configure the agent, and OpenAI provisions the environment. You give it a task, and once the environment is ready your input starts a turn of work. You follow progress by streaming output, or use webhooks to learn when the agent finishes or needs input. Then you send another task to the same session, or steer the agent while its current turn is still running.
The session keeps its state between turns, so your application doesn’t rebuild the conversation context on each call. With an OpenAI-hosted session, your side only sends input and receives events. OpenAI runs the agent and provisions and manages its sandbox.
The managed harness covers the parts a team would otherwise have to build and maintain around a model:
- running commands and code in a sandbox;
- applying relevant skills and instructions;
- connecting to external data through tools or MCP;
- steering the agent while it works;
- summarizing previous work to manage its context window;
- breaking work into subtasks and delegating them to subagents;
- resuming a session where it left off.
Inside the sandbox, agents can execute code, edit files, connect to MCP servers and produce artifacts. Context compaction, which summarizes earlier work so a long session still fits the model’s window, is one of the pieces OpenAI now runs for you.
The documentation’s example shows most of the configuration in a single client.beta.agents.sessions.create call. The agent runs on gpt-6-astra. Its instructions tell it to use the OpenAI documentation MCP and web search for technical questions, and to delegate independent research to subagents when useful. Three tools are attached: programmatic_tool_calling, an MCP server labelled openai_docs reached over HTTP at https://developers.openai.com/mcp, and web_search.
Multi-agent work is switched on per session with "multi_agent": {"enabled": True, "max_concurrent_subagents": 4}, so the fan-out ceiling is a setting you choose. One of the runnable examples in the docs uses the same mechanism: subagents compare release notes, and their findings are combined into one answer.
The example environment is self-hosted rather than an OpenAI sandbox. It sets "type": "self_hosted", a workspace_directory of /workspace, and a capability_directories entry pointing at /workspace/capabilities/skills, which is where the agent picks up its skills. The first user message goes into the same call, so creating the session also starts the first turn. Setup and limitations for each environment type sit on a separate environment-options page.
Billing adds no new line of its own. Model usage is billed at the selected model’s API rates, OpenAI tools at their standard rates, and OpenAI-hosted sandboxes at standard container rates.
The data terms are narrower. The Agents API supports data residency only in the United States, and it does not support Zero Data Retention, the arrangement under which OpenAI keeps no request data. Choosing a self-hosted sandbox does not make the API ZDR-eligible. You can delete sessions and published artifacts once you no longer need them.
Besides the release-notes comparison, OpenAI ships a second runnable example, a directory-tree script created and run in an OpenAI-hosted sandbox. Five complete applications show the jobs it has in mind: an incident response agent that investigates alerts and asks for approval before recovery actions, a Slack bot that handles requests using connected workplace tools, a data analyst that answers warehouse questions with read-only SQL, a GitHub issue investigator that reproduces reported bugs and shares its findings on GitHub, and a document reviewer that works with policy skills and specialist agents.
The quickstart starts with an OpenAI-hosted sandbox. Before the first call, check its prerequisites, which list the API-key permissions and SDK setup it expects.
Up next
Four of five Claude cells retain prompts by default
Four of the five Anthropic model-and-tier cells ProvenBrief’s new retention tracker could verify keep prompts by default, and Claude Fable 5.1 in GitHub Copilot won’t run at all unless Anthropic stores them.
Related stories
- Codex keeps coding in the cloud after your laptop closes
- Three ways to embed the Codex agent loop in your app
- OpenAI gives its Open Responses API spec to the AAIF
- OpenAI’s MCP Extensions put plugins in the ChatGPT sidebar
- OpenAI opens ChatGPT’s 1.2B weekly users to developers
- Two sample agents run code to drive browser and desktop
Comments
No comments yet. Be the first.
Join the conversation
Sign in to leave a comment. It appears after moderation.

