OpenAI Agents API
TL;DR Highlight
OpenAI launched a managed agents API handling sessions, context compaction, and recovery.
Who Should Read
Backend developers who find building and operating their own agent harness too burdensome
Core Mechanics
- Codex harness offered as an API
- The Agents API exposes an OpenAI-managed Codex harness (the agent runtime) through an API.
- OpenAI handles sessions, orchestration, context compaction, and recovery.
- Your app provides tools and picks the execution environment.
- Four core concepts
- An Agent bundles the model, instructions, tools, and MCP servers.
- An Environment is an optional sandbox or computer for files, skills, and commands.
- A Session is a durable agent instance that keeps working on tasks.
- Events and items are the inputs and outputs.
- What the harness gives you out of the box
- It runs commands and code in a sandbox.
- It supports skills, external data via MCP, and steering mid-turn.
- It summarizes prior work for context, delegates to subagents, and resumes sessions.
- Session flow: create, task, follow, continue
- Creating a session makes OpenAI provision the environment.
- Stream output or use webhooks to track progress and input requests.
- Send more tasks to the same session or steer the current turn.
- Choose hosted or self-hosted environment
- With a hosted sandbox, OpenAI runs the agent and manages the sandbox.
- The sample code sets environment type to self_hosted with a workspace_directory.
- Pricing uses existing rates
- Model usage is billed at the selected model's API rates.
- OpenAI tools use standard rates and hosted sandboxes use standard container rates.
Community Reactions
- Self-hosted sandbox seen as a plus
- One comment noted you can self-host the sandbox, which could ease switching providers.
- Other comments raised heavy lock-in concerns.
- Remote agent seen as backwards
- A commenter said the hard part is giving agents access to local data, and a remote agent reaching into your infra makes it worse.
- They would rather run the agent locally with remote hosted sandboxes.
- Data retention flagged as unclear
- A commenter pointed out a note saying it isn't eligible for Zero Data Retention.
- They worried the don't-train toggle covers only user-visible inputs and outputs, not reasoning traces.
- Mixed build-vs-buy experience
- One commenter built sandbox and Slack integrations with the OpenAI agents SDK and kept strict control over what was exposed.
- Another argued teams can't keep pace with API changes, so they end up on hosted abstractions.
- A commenter said the example GitHub links first 404ed, then were fixed to openai-cookbook.
How to Apply
- Run the docs-MCP session example
- Run the session-creation code below with your API key and print session.id.
- Replace the question with one from your own service.
- Compare responsibilities with your own harness
- List which of session storage, context compaction, and recovery you built yourself.
- Mark which overlap with the Agents API built-ins.
- Check data retention terms first
- If customer data will flow in, verify the Zero Data Retention ineligibility note before adopting.
- Use the self-hosted sandbox option and keep access minimal.
- Try one parallel subagent task
- Pick an independent research task and enable multi_agent.
- Set max_concurrent_subagents to 4 and check that results merge into one answer.
Try It
# Run in a terminal (pip install openai; needs an OpenAI API key and Agents API beta access)
from openai import OpenAI
client = OpenAI()
session = client.beta.agents.sessions.create(
agent={
"model": "gpt-6-astra",
"instructions": "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.",
"tools": [
{"type": "programmatic_tool_calling"},
{
"type": "mcp",
"server_label": "openai_docs",
"transport": {"type": "http", "server_url": "https://developers.openai.com/mcp"},
},
{"type": "web_search"},
],
"multi_agent": {"enabled": True, "max_concurrent_subagents": 4},
},
environment={
"type": "self_hosted",
"workspace_directory": "/workspace",
"capability_directories": ["/workspace/capabilities/skills"],
},
input=[{"role": "user", "content": [{"type": "input_text", "text": "{{question}}"}]}],
)
print(session.id)
# Next: change the question, turn multi_agent off, and compare results.Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques