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.
Hiring a Codex agent
Agents → Hire → Codex. Same fields as the Claude Code flow, with the model field picking between OpenAI models:o-seriesmodels (reasoning)gptmodels (general-purpose coding)
What the adapter does at run time
Identical to the Claude Code adapter, with the binary swapped:- Create the workspace
- Write role files
- Launch
codexwith lease token and MCP URL in env vars - Parse structured tool-call events from Codex stdout
- Relay tool calls to the MCP server
- Renew the lease
- On exit, call
mark_completeormark_failed
Environment variables
| Variable | Purpose |
|---|---|
OPENAI_API_KEY | Auth for Codex |
CODEX_BIN | Binary name (default codex) |
CODEX_MODEL | Default model if the agent didn’t pick one |
CODEX_EXTRA_ARGS | Extra args passed verbatim to codex |
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 inpackages/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, withcodex in place of
claude. Common failures:
codexnot on PATH for the orchestrator’s user- Missing
OPENAI_API_KEYin the orchestrator’s environment - Tool permission denied because the agent’s policy does not include the tool Codex tried to call
Next
- Claude Code adapter for the Anthropic equivalent
- Process adapter for other CLI runtimes
- Creating an adapter for writing your own