Codex is OpenAI’s interactive agent CLI. The Codex adapter works almost identically to the Claude Code adapter but targets the Codex binary. If you have read the Claude Code page, most of this will feel familiar.

Prerequisites

  • Codex CLI installed and on your PATH as codex. Install instructions at github.com/openai/codex.
  • An OpenAI API key exported as OPENAI_API_KEY, or sign into Codex once so the adapter reuses your session.
  • Company Agents orchestrator running, with the MCP server reachable at http://localhost:4200.
Verify:
codex --version
# => codex 0.x.x

Hiring a Codex agent

Agents → Hire → Codex. Same fields as the Claude Code flow, with the model field picking between OpenAI models:
  • o-series models (reasoning)
  • gpt models (general-purpose coding)
From the CLI:
company-agents agent hire \
  --adapter codex \
  --name "Backend Engineer" \
  --role ic-engineer \
  --team engineering \
  --model o4-mini \
  --task-budget 1.50

What the adapter does at run time

Identical to the Claude Code adapter, with the binary swapped:
  1. Create the workspace
  2. Write role files
  3. Launch codex with lease token and MCP URL in env vars
  4. Parse structured tool-call events from Codex stdout
  5. Relay tool calls to the MCP server
  6. Renew the lease
  7. On exit, call mark_complete or mark_failed
The one material difference is the stdio format: Codex and Claude Code emit different JSON shapes for tool events. The adapter knows both; the agent author does not.

Environment variables

VariablePurpose
OPENAI_API_KEYAuth for Codex
CODEX_BINBinary name (default codex)
CODEX_MODELDefault model if the agent didn’t pick one
CODEX_EXTRA_ARGSExtra args passed verbatim to codex
And the same MCP_SERVER_URL, CA_LEASE_TOKEN, CA_FENCING_TOKEN, CA_TASK_ID, CA_RUN_ID as the Claude Code adapter.

MCP tools

Same tool set as Claude Code. The agent’s policy still decides which tools are exposed; the adapter filters them out of the MCP registration before Codex starts.

Cost accounting

Codex reports token counts per model call. The adapter parses them out of the stdio stream and reports them to the cost layer. Pricing is table-driven in packages/db/src/pricing/openai.ts. If you route Codex through OpenRouter or a proxy via LLM_BASE_URL, pricing still uses the underlying model name.

Known quirks

  • Codex and shell commands: Codex has a shell tool that defaults to running in the current working directory. The adapter starts Codex with the workspace as cwd so shell commands stay inside the run sandbox.
  • Sandbox level: Codex has a few sandbox modes. The adapter forces the strictest available mode that still allows file writes within the workspace.
  • Tool approval: Codex has its own tool approval prompts in interactive mode. The adapter runs Codex in non-interactive mode and routes any “requires approval” tool through the orchestrator’s approval flow instead.

Debugging

Same as the Claude Code adapter, with codex in place of claude. Common failures:
  • codex not on PATH for the orchestrator’s user
  • Missing OPENAI_API_KEY in the orchestrator’s environment
  • Tool permission denied because the agent’s policy does not include the tool Codex tried to call

Next