AnyAgent

Codex

Use Codex through AnyAgent: what you can ask for, how it behaves, and the flags underneath.

The codex adapter drives the Codex CLI through its non-interactive codex exec --json mode, detected as the codex binary on PATH; import codex from anyagent/codex.

What you can ask for

readOnly, model, effort, resume, and attachments map to the CLI’s own flags; systemPrompt and schema are provided by AnyAgent. mcp is not declared; reach Codex’s -c config overrides via extraArgs. authStatus() asks codex login status and models() asks codex debug models. The full grid is on the support matrix.

Good to know

  • effort has no closed vocabulary; accepted values are per-model, listed by models() on ModelInfo.reasoningEfforts.
  • The thread.started id lands on result.sessionId; pass it back as resume.
  • Cache reads fold into the input total and reasoning into the output total; cacheReadTokens and reasoningTokens report those shares, not additions. No cost is reported.

Under the hood

Every run executes codex exec --json --sandbox danger-full-access with the prompt piped over stdin through the - positional. Run options change the sandbox and append flags:

OptionFlag
readOnly: true--sandbox read-only
model--model <name>
effort-c model_reasoning_effort="<value>", passed through verbatim
attachments-i <file>…, every path on one flag, ahead of the - stdin positional
resumecodex exec resume <threadId>, with the sandbox set via -c sandbox_mode="…"

On this page