Harness Codex: what it changes for your agents
With Harness Codex, OpenAI integrates agent execution directly into its runtime. A major simplification that redefines AI architecture.
OpenAI shifts part of the value of LLMs toward their execution runtime. With the Agents API, some functions historically handled by third-party orchestration layers—session management, context, tools or sub-agents—can now be delegated directly to OpenAI’s infrastructure.
Agents API: OpenAI exposes the Codex harness to developers
Why it matters now... Launched on September 10, 2026, in public beta, the Agents API illustrates the gradual shift from competing on models alone to competing on the environments that let models work persistently. OpenAI now exposes to developers the same type of harness and agent infrastructure behind Codex.
The key takeaway
The Agents API provides a managed Codex harness capable of handling durable sessions, context compaction, tool use, MCP and coordination of sub-agents. Developers can choose an OpenAI-hosted sandbox, connect their own infrastructure or use a compatible partner. This evolution reduces some agent plumbing without making specialized orchestrators obsolete.
Contents
- Why this matters now
- What it is
- What you can use it for
- Operational impact and ROI
- How to use it
- Pricing and business model
- Alternatives to consider
- A practical example
- Implementation guide
- Risks and limitations
- Questions to ask before you decide
- The KingLand verdict
- An AI explorer’s perspective
Why this matters now
The AI market in 2026 is no longer focused solely on context window size or raw model power. Companies also want agents that can run long tasks, handle files, use multiple tools and resume work across turns. This trend pushes model providers to offer more components at the execution layer.
In 2024 and 2025, many teams had to assemble several infrastructure bricks: state storage, memory mechanisms, isolated environments for code execution and orchestrators coordinating calls to models and tools. Some applications also relied on stateless architectures around the OpenAI API, forcing developers to manage part of the application context themselves.
With the Agents API, some of that complexity can now be absorbed by a managed layer. Third-party orchestrators don't disappear: they remain relevant when a company needs fine-grained workflow control, multi-model architectures, specific durable execution, or greater independence from a provider.
What it is
The Agents API is a managed OpenAI API designed to create and run agents built on the Codex harness. A session preserves the agent’s configuration, conversation and saved work to allow successive interactions and asynchronous tasks. The environment where the agent handles files or runs code can be hosted by OpenAI, run on developer-controlled infrastructure, or provided by a compatible partner.
Technology in brief
The Agents API pairs an OpenAI-managed agent harness with durable sessions and configurable execution environments. The OpenAI sandbox is one option: the core Codex harness is open source and execution environments can also be self-hosted or partner-provided.
In an OpenAI-hosted sandbox, the agent has an isolated environment to run code, work with files and produce artifacts. Developers can configure files, packages, skills, plugins and network access rules. OpenAI allows disabling network output or restricting it to an allowlist of domains, giving extra control over code-generated capabilities.
The runtime also includes automatic context compaction. When a session nears a model’s context limit, earlier elements can be compacted to preserve information useful for current work. Tool Search can also load only relevant tool definitions, which can limit context consumption when many tools are available.
What you can use it for
The Agents API reduces part of the agent plumbing by handling the agent loop, sessions, context management and coordination of certain tools or sub-agents. Choosing OpenAI’s hosted sandbox can also avoid running your own code execution and file-handling environment.
Key features address three major operational needs:
- Code execution in an isolated environment: The agent can execute commands, manipulate files and produce artifacts in a controlled sandbox, with network policies and resources depending on the chosen environment.
- Interoperability via MCP and tools: The Agents API supports MCP servers, custom functions and multiple built-in tools. MCP makes connecting to compatible external systems easier, without automatically making every data source interoperable.
- Durable sessions: A session retains its configuration, conversation and saved work to continue a workflow across multiple turns. In an OpenAI sandbox, workspace files persist while the sandbox exists; an inactive sandbox that receives no keep-alive may expire.
Multi-agent support also lets a primary agent delegate independent subtasks to several sub-agents, each with its own context, then aggregate their results.
Operational impact and ROI
Introducing a managed runtime can reduce the amount of code and infrastructure a team must maintain. The economic impact, however, strongly depends on the number of sessions, models used, token volume, enabled tools, execution duration and the architecture the Agents API replaces.
For CTOs and engineering directors
- Benefit: Potential reduction in maintenance for agent loops, context management, sessions and some coordination mechanisms. Actual savings should be measured on the company's workloads rather than inferred from a generic percentage.
- Usage: Standardization of part of the agent lifecycle while keeping the choice between OpenAI sandbox, self-hosted infrastructure or partner providers.
For senior software architects
- Benefit: Possible acceleration of delivery cycles by reducing orchestration-specific code and gaining direct access to session, tool, sub-agent and execution environment primitives.
- Usage: Designing long or parallel agentic workflows using managed sessions and multi-agent support, subject to rate limits and model constraints.
Return on investment is therefore not automatic. OpenAI publishes customer reports of cost or latency reductions on their workloads, but these results are specific to their architectures and must be reproduced by benchmarking before extrapolating.
How to use it
Integrating the Agents API involves defining an agent, its tools and environment, then creating sessions that can continue work across turns. The developer retains control over the capabilities exposed to the agent and where code is executed.
- Define the agent and its environment: Choose the model, instructions, tools and, if needed, multi-agent mode. Then select an OpenAI sandbox, self-hosted infrastructure or a partner integration.
- Configure tools and access: Declare MCP servers, functions or other authorized tools. For MCP connections managed by OpenAI, Vaults can store credentials without exposing their secret values to the agent.
- Initialize a session: Create a session via the OpenAI SDK and provide an initial input. The session then preserves the configuration, conversation and saved work.
- Track the asynchronous workflow: Consume events via streaming or use webhooks to follow execution state, action requests and end of turns.
- Manage the lifecycle: Resume an existing session, cancel an active turn or delete the session when it’s no longer needed. The sandbox lifecycle must be managed separately from persistent session data.
This approach can make it easier to add advanced agent capabilities to an existing app, but migration must consider persistence mechanisms, permissions, costs and security constraints specific to the project.
Pricing and business model
At public beta launch, OpenAI states it is not charging additional fees specifically for using the Agents API. Developers still pay for the models, tools and environments consumed by their agents at applicable rates.
Costs break down across three key variables:
- Inference token billing: Inputs and outputs are billed at the rate of the chosen model. Context compaction and selective tool loading can help limit some consumption, without guaranteeing fixed cost reductions.
- Cost of the hosted sandbox: OpenAI environments use standard container rates. At the time of this check, the pricing page lists $0.03 for 1 GB, $0.12 for 4 GB, $0.48 for 16 GB and $1.92 for 64 GB per 20-minute reference block; OpenAI also notes eligible sessions may be billed by the minute with a five-minute minimum.
- Additional tools and services: Potentially billable integrated tools, service-specific storage and partner-provided environments may add their own costs. The current documentation lists no generic monthly state-storage pricing specific to the Agents API.
Prices should be checked on the official page at publication time, as model, tool and container pricing can change quickly during the beta.
Alternatives to consider
Native OpenAI integration can reduce infrastructure work, but it also increases dependency on its API and session primitives. This risk is less absolute than in a fully closed architecture: the Codex harness is open source and the Agents API allows multiple execution environments, including developer-controlled infrastructure.
The frameworks LangGraph remains an important option for teams seeking fine control over transitions, persistence, human-in-the-loop and durable workflows, while retaining the ability to use different model providers. Meanwhile, OpenClaw has its own agent runtime, with workspaces and session storage, and may suit architectures where teams want greater control over the execution environment.
Finally, for secure execution of AI-generated code, specialized solutions like E2B and Vercel Sandbox are alternatives or complementary options. OpenAI lists them among first-class partner integrations with the Agents API, alongside Cloudflare, Daytona, DigitalOcean, Modal, Oracle and Runloop.
A practical example
The following scenario illustrates the kind of software maintenance workflow the Agents API can orchestrate. It is not a measured benchmark and actual performance depends on the repository, model, tools and environment used.
The prompt / the action
“Initialize an Agents API session. Connect to the repository via the authorized MCP server. Analyze the three most recent open issues about memory leaks. Generate a fix and a reproduction test, run the tests in the sandbox, then prepare a Pull Request when validations succeed.”
The result
In a properly authorized configuration, the agent can use the MCP server to read issues and the repo, work on files in its environment, run tests, save artifacts and continue the workflow across multiple turns. The result, duration and token consumption must be measured on the real project: no fixed latency or token reduction can be inferred from architecture alone.
What can go wrong
A command, an MCP tool or an environment can fail depending on permissions, network policy, available resources or the sandbox lifecycle. OpenAI sandboxes may also expire if they receive no activity or keep-alive for one hour. Events, saved session elements and observability functions must therefore be part of production workflow diagnostics.
Implementation guide
Migration to an Agents API–based architecture should be gradual to compare behavior with existing orchestration and validate cost, security and data-retention requirements.
Phase 1: initial configuration
Objective: Declare a first agent and its execution environment.
Action: Define the model, instructions and tools, then configure the environment with necessary files, packages and network rules. Use an OpenAI sandbox or select external infrastructure suited to the project's constraints.
Expected result: A session whose environment reaches operational state and can begin executing authorized tasks.
Phase 2: first connected workflow
Objective: Validate the operation of a tool connected via MCP and the production of an artifact.
Action: Start an agent session tied to the configured environment, ask it to query a test source via an MCP server, extract a data sample, generate an analysis in the sandbox and save the result to the outputs directory.
Expected result: Retrieve an artifact produced by the agent and validate the complete path between session, external tool, execution environment and result storage.
Phase 3: deployment
Objective: Gradually migrate production workflows for which the Agents API provides a measurable advantage.
Action: Replace only orchestration loops validated for Agents API sessions. Configure webhooks, events, network policies, authentication mechanisms and session deletion procedures required for production context.
Expected result: A potentially leaner backend architecture, with more centralized management of agent sessions and observability relying on events, session elements and available tracing tools.
Risks and limitations
Adopting a managed runtime introduces new trade-offs between operational simplicity, infrastructure control, data persistence and vendor dependency. Security and compliance requirements must be analyzed.
| Technical criteria | Agents API + OpenAI sandbox | Hybrid orchestration (self-hosted) |
|---|---|---|
| Vendor lock-in | Moderate to high. The API and sessions are specific to OpenAI, even though the Codex harness is open source and the execution environment can be externalized. | Variable but potentially lower when the architecture abstracts the model provider and runtime. |
| Data sovereignty | To be evaluated precisely. /v1/agents objects currently retain their application state until deleted and are not eligible for Zero Data Retention. | Potentially greater control over environment and files, subject to where model inference and external services are run. |
| Rate limit management | Quotas are managed by the platform, but the application must still handle errors, retries, model limits and load spikes. | Generally requires more queuing logic, throttling and retry mechanisms on the application side. |
| Observability and logs | Events, session elements, usage metrics and tracing are available, without full access to OpenAI’s underlying infrastructure. | Possibility of deeper system observability when the environment and orchestrator are fully controlled by the company. |
Ideal for: Projects wanting to speed deployment of agents using multiple tools, long sessions, context compaction or sub-agents, while reducing some orchestration maintenance.
Watch points: Public beta status, evolving pricing for models and containers, sandbox lifecycle, MCP service policies and, above all, the data-retention rules of the /v1/agents endpoint must be included in architecture analysis.
Avoid if: Your internal policy requires Zero Data Retention for agent session state or residency and processing constraints that the chosen configuration cannot meet. In such cases, evaluate a hybrid architecture or a fully controlled runtime before deployment.
Questions to ask before you decide
[CTO] Does moving to the Agents API make frameworks like LangGraph obsolete?
No. LangGraph remains relevant for defining durable, stateful workflows, deterministic transitions, human validations, custom retry mechanisms or architectures using multiple model providers. The Agents API reduces some plumbing layers but does not replace all application orchestration needs.
[Ops / Product] How are secrets and third-party API keys handled inside the runtime?
For MCP connections executed from OpenAI’s service, Vaults can store credentials without returning secret values to the agent. OpenAI also recommends keeping third-party credentials out of the execution environment when possible and using a credential broker to inject permissions only into approved requests. The application’s primary API key should not be placed in the sandbox.
[CTO] What is the real impact on response latency for the end user?
The Agents API can eliminate some round trips and coordination code previously handled by an application orchestrator. OpenAI presents customer testimonials reporting significant gains on certain workflows, but no universal latency reduction factor is guaranteed. Results must be measured on the actual tasks, tools and models used.
[Beginner] Can this service be used with open-weight models hosted locally?
The Agents API is a managed OpenAI service designed around models supported by its platform. The supporting Codex harness is open source, however. To run an open-weight local model directly or adopt a multi-vendor architecture, you generally need a suitable runtime or framework like LangGraph, OpenClaw or custom orchestration.
The KingLand verdict
Note: 4.3 / 5
The Agents API marks an important step in the maturation of OpenAI’s agent infrastructure. By exposing the Codex harness, durable sessions, context compaction, sub-agents and multiple execution environment options, OpenAI does reduce some friction that still separated agent prototypes from production systems. The benefit is especially strong for teams wanting to accelerate implementation without rebuilding every coordination component. The trade-off remains increased dependency on OpenAI’s control plane and persistence mechanisms: the application state of /v1/agents is currently retained until deletion and is not eligible for Zero Data Retention. Public beta status also justifies a validation phase before any critical migration.
An AI explorer’s perspective
Observing this technical shift reveals a deeper move than a simple API update. With the Agents API, OpenAI clearly aims to occupy more of the layer between the raw model and the final application: sessions, context, tools, sub-agents and execution environments become primitives offered directly by the provider. This evolution pressures specialized frameworks but does not doom them. The Codex harness itself is open source and runtimes like LangGraph continue to meet needs for control, persistence, portability and orchestration that the managed service does not necessarily seek to replace.
The essential question becomes the right level of abstraction. Delegating the agent loop and part of context management can accelerate development significantly, but it also hands over more operational state to an external service. The challenge for architects will likely not be choosing definitively between managed infrastructure and autonomy, but designing systems that use these new primitives effectively while keeping clear boundaries around data, tools, execution environments and mechanisms that are strategically important to the business.