# OpenAI's Agents API hands you the Codex harness

> OpenAI now runs the agent loop for you: sessions, sandboxes, subagents, and context compaction behind one API.
- Title: OpenAI's Agents API hands you the Codex harness | Shortify
- Summary: OpenAI now runs the agent loop for you: sessions, sandboxes, subagents, and context compaction behind one API. You bring the tools and pick the execution…
- Keywords: openai, agents, codex, mcp, sandboxes, technology, startups, OpenAI's, API, hands, harness, OpenAI Developers
- Source: OpenAI Developers — https://developers.openai.com/api/docs/guides/agents-api/overview
- Read time: 2 min
- Topics: openai, agents, codex, mcp, sandboxes, technology, startups
## Codex, now as an API
The Agents API opens up the same Codex harness through an OpenAI-managed endpoint. You call it, OpenAI runs the loop.

> The Agents API gives your application access to the Codex harness through an OpenAI-managed API.
## Who owns what
OpenAI handles sessions, orchestration, context compaction, and recovery. Your app supplies the tools and picks where the agent actually runs.
## A sandbox with real hands
Agents can execute code, edit files, talk to MCP servers, and leave behind artifacts. This is a working machine, not a chat box.

> Agents can operate in a sandbox where they can execute code, edit files, connect to MCP servers, and produce artifacts.
## Three separate meters
Model usage bills at the chosen model's API rates, OpenAI tools at their standard rates, and OpenAI-hosted sandboxes at container rates.
## Start from a working example
Run a directory-tree script in a hosted sandbox, or have subagents compare release notes and merge their findings into one answer.
## What people build with it
Reference apps cover incident response with approval gates, a Slack investigator, a read-only SQL data analyst, a GitHub bug reproducer, and a policy-driven document reviewer.
## Four concepts, that's it
Agent is the model plus instructions, tools, and MCP servers. Environment is the sandbox. Session is a durable running instance. Events and items are the input and output.
## The shape of a session
Create a session and OpenAI provisions the environment. Send a task, stream progress or wait on a webhook, then send more work or steer mid-turn.
## What the harness does for you
Running commands, applying skills, reaching external data via MCP, accepting steering mid-task, summarizing old work, delegating to subagents, and resuming later.
## Capabilities are config
One create call wires it all up: a model, instructions, a tools array with programmatic tool calling, an MCP server, and web search, plus multi_agent settings.

> "multi_agent": { "enabled": true, "max_concurrent_subagents": 4 }
## Bring your own box
The environment block can point at a self-hosted sandbox with your own workspace directory and capability directories for skills.
## State survives the turn
Sessions retain state, so you continue work without rebuilding conversation context. Delete sessions and published artifacts when you no longer want them around.

> The Agents API retains session state so you can continue work across turns without rebuilding the conversation context.
## Read the data rules first
US data residency only, and no Zero Data Retention. Running your own sandbox does not change that, so regulated workloads need a closer look before you build.

> Choosing a self-hosted sandbox does not make the Agents API ZDR-eligible.
## Key takeaway

You bring the tools and pick the execution environment; OpenAI runs everything else, but only in the US and never with zero data retention.