Skip to content

Codex agents provide AgentPool's integration with the Codex app-server, enabling advanced code editing, terminal access, and tool execution through Codex's JSON-RPC protocol.

Overview

AgentPool integrates directly with Codex app-server via its JSON-RPC protocol, providing:

  • Native Codex features: Full access to Codex's reasoning, tools, and model capabilities
  • Low latency: Direct process communication via stdin/stdout
  • Toolset bridging: Expose AgentPool's internal toolsets to Codex via MCP
  • Streaming events: Real-time event propagation from Codex to AgentPool
  • Structured outputs: Support for typed response schemas via JSON Schema

Codex agents are ideal for:

  • Complex coding tasks with extended reasoning
  • Terminal operations and shell command execution
  • Multi-file refactoring and code generation
  • Tasks benefiting from Codex's reasoning effort levels

Configuration Reference

Codex Agent Configuration

Configuration for Codex app-server agent.

Wraps the Codex app-server via its JSON-RPC protocol, enabling integration with agentpool's agent ecosystem.

Codex Agent Configuration (YAML)
type: codex  # Top-level discriminator for agent type.
model: null  # Model to use for the Codex session.
reasoning_effort: null  # Reasoning effort level for the model.
approval_policy: never  # Tool call approval policy.
sandbox: workspace-write  # Sandbox mode for file operations.
base_instructions: null  # Base system instructions for the Codex session.
developer_instructions: null  # Developer-provided instructions for the Codex session.
tools: []  # Tools and toolsets to expose to Codex via MCP bridge.
output_type: null  # Optional structured output type for responses. Can be either a reference to a response defined in ma...
requires_tool_confirmation: per_tool  # How to handle tool confirmation:
hooks: null  # Hooks for intercepting and customizing agent behavior at key lifecycle points.
environment: null  # Execution environment config for the agent's own toolsets.
name: null  # Identifier for the node. Set from dict key, not from YAML.
display_name: null  # Human-readable display name for the node.
description: null  # Optional description of the agent / team.
triggers: []  # Event sources that activate this agent / team
connections: []  # Targets to forward results to.
mcp_servers: []  # List of MCP server configurations:
input_provider: null  # Provider for human-input-handling.
event_handlers: []  # Event handlers for processing agent stream events.

Examples

Basic Configuration

A minimal Codex agent for coding tasks:

agents:
  codex_coder:
    type: codex
    cwd: /path/to/project
    model: gpt-5.1-codex-max
    reasoning_effort: medium

Reasoning Effort Levels

Control how deeply Codex reasons about tasks:

agents:
  quick_helper:
    type: codex
    model: gpt-5.1-codex-max
    reasoning_effort: low  # Fast responses

  deep_thinker:
    type: codex
    model: gpt-5.1-codex-max
    reasoning_effort: high  # Complex problem solving

Tool Approval Policies

Configure how Codex handles tool execution approval:

agents:
  auto_executor:
    type: codex
    approval_policy: never  # Execute tools without approval (default)

  safe_agent:
    type: codex
    approval_policy: auto  # Auto-approve safe tools, ask for risky ones

  interactive:
    type: codex
    approval_policy: always  # Always request approval

Toolset Integration

Expose AgentPool's internal toolsets to Codex via MCP:

agents:
  codex_coordinator:
    type: codex
    cwd: /path/to/project
    tools:
      # Delegate to specialized agents
      - type: subagent
        agents:
          - researcher
          - writer

      # File operations
      - type: file_access

      # Bash commands
      - type: bash

      # Custom tools
      - my_module:my_tool

This allows Codex to use AgentPool's toolsets alongside its native capabilities.

Structured Output

Define typed responses using JSON Schema:

responses:
  bug_report:
    type: object
    properties:
      title: { type: string }
      severity: { type: string, enum: [critical, high, medium, low] }
      steps_to_reproduce:
        type: array
        items: { type: string }
      affected_files:
        type: array
        items: { type: string }
      suggested_fix: { type: string }

agents:
  bug_finder:
    type: codex
    output_type: bug_report

Then use structured output programmatically:

from agentpool import AgentPool
from pydantic import BaseModel

class BugReport(BaseModel):
    title: str
    severity: str
    steps_to_reproduce: list[str]
    affected_files: list[str]
    suggested_fix: str

async with AgentPool("config.yml") as pool:
    agent = pool.get_agents()["bug_finder"]

    # Configure for structured output
    agent.to_structured(BugReport)

    result = await agent.run("Analyze the authentication code for bugs")
    # result is now a BugReport instance
    print(f"Found {result.title} with severity {result.severity}")

External MCP Servers

Connect Codex to external MCP servers:

mcp_servers:
  filesystem:
    transport: stdio
    command: mcp-server-filesystem
    args: ["/path/to/workspace"]

agents:
  codex_with_fs:
    type: codex
    mcp_servers:
      - filesystem

Reasoning Effort Modes

Codex supports three reasoning effort levels that can be changed at runtime:

Mode Description Use Case
low Fast, minimal reasoning Quick edits, simple tasks
medium Balanced reasoning General purpose (default)
high Deep reasoning Complex problem solving, architecture

Example runtime mode switching:

from agentpool import AgentPool

async with AgentPool("config.yml") as pool:
    agent = pool.get_agents()["my_codex"]

    # Switch to high reasoning for complex task
    await agent.set_mode("high", category_id="reasoning_effort")
    result = await agent.run("Design a scalable authentication system")

    # Switch back to medium for normal tasks
    await agent.set_mode("medium", category_id="reasoning_effort")

Approval Policy Modes

Control when Codex requests permission to execute tools:

Policy Description
never Execute tools without approval (default for programmatic use)
auto Auto-approve low-risk tools, request approval for high-risk
always Always request approval before executing any tool

Change approval policy at runtime:

await agent.set_mode("always", category_id="approval_policy")

Model Selection

Codex provides access to various models. The agent can dynamically fetch available models:

from agentpool import AgentPool

async with AgentPool("config.yml") as pool:
    agent = pool.get_agents()["my_codex"]

    # Get available models
    models = await agent.get_available_models()
    for model in models:
        print(f"{model.name}: {model.description}")

    # Switch model
    await agent.set_model("gpt-5.1-codex-mini")

Common Codex models:

  • gpt-5.1-codex-max - Most capable, best for complex tasks
  • gpt-5.1-codex-mini - Faster, cost-effective
  • gpt-5-codex - Previous generation
  • claude-opus-4 - Anthropic Claude integration

Thread Management

Codex uses threads to maintain conversation context. Some settings (model, reasoning_effort) require creating a new thread:

# These require thread restart (archive old, create new):
await agent.set_model("new-model")
await agent.set_mode("high", category_id="reasoning_effort")

# This doesn't require restart:
await agent.set_mode("always", category_id="approval_policy")

Comparison with Claude Code Agents

Feature Codex Agent Claude Code Agent
Protocol Codex JSON-RPC Claude Agent SDK
Reasoning control 3 effort levels Extended thinking tokens
Tool approval 3 policies (never/auto/always) 4 permission modes
Models Codex models + Claude Claude models only
Thread management Archive + restart Session reconnect
Structured output Via JSON Schema Via result tools

Choose Codex agents for:

  • Access to Codex-specific models and reasoning
  • Projects already using Codex
  • Tasks benefiting from Codex's reasoning effort system

Choose Claude Code agents for:

  • Pure Claude model access
  • Extended thinking capabilities
  • Tighter Claude ecosystem integration