Codex Managed Agents

Codex Managed Agents overview

Codex Managed Agents provides the harness and infrastructure for running Codex as an autonomous agent. Instead of building your own agent loop, tool execution, and runtime, you get a fully managed environment where Codex can read files, run commands, browse the web, and execute code securely. The harness supports built in prompt caching, compaction, and other performance optimizations for high quality, efficient agent outputs.

Core concepts

Codex Managed Agents is built around four concepts:

ConceptDescription
AgentThe model, system prompt, tools, MCP servers, and skills
EnvironmentA configured container template (packages, network access)
SessionA running agent instance within an environment, performing a specific task and generating outputs
EventsMessages exchanged between your application and the agent (user turns, tool results, status updates)

How it works

Create an agent

Define the model, system prompt, tools, MCP servers, and skills. Create the agent once and reference it by ID across sessions.

Create an environment

Configure a cloud container with pre-installed packages (Python, Node.js, Go, etc.), network access rules, and mounted files.

Start a session

Launch a session that references your agent and environment configuration.

Send events and stream responses

Send user messages as events. Claude autonomously executes tools and streams back results via server-sent events (SSE). Event history is persisted server-side and can be fetched in full.

Steer or interrupt

Send additional user events to guide the agent mid-execution, or interrupt it to change direction.

When to use Codex Managed Agents

Codex Managed Agents is best for workloads that need:

  • Long-running execution - Tasks that run for minutes or hours with multiple tool calls
  • Cloud infrastructure - Secure containers with pre-installed packages and network access
  • Minimal infrastructure - No need to build your own agent loop, sandbox, or tool execution layer
  • Stateful sessions - Persistent file systems and conversation history across multiple interactions

On this page