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
efforthas no closed vocabulary; accepted values are per-model, listed bymodels()onModelInfo.reasoningEfforts.- The
thread.startedid lands onresult.sessionId; pass it back asresume. - Cache reads fold into the input total and reasoning into the output total;
cacheReadTokensandreasoningTokensreport 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:
| Option | Flag |
|---|---|
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 |
resume | codex exec resume <threadId>, with the sandbox set via -c sandbox_mode="…" |