codex harness runs the OpenAI Codex CLI non-interactively in a benchmark-prepared workspace.
How it works
- Prepare Codex CLI. An optional Runtime Capsule supplies Node/npm first; if
codexis absent, the harness then appliesinstall_strategyandinstall_command. - Configure and run. The harness writes a session-scoped Codex provider configuration and invokes the CLI non-interactively in the task workspace. Recipes may place this configuration outside the repository so it cannot enter a generated patch.
- Collect results. The trajectory comes from the session rollout Codex writes under its config home: one step per model call, with every tool call that call requested, the matching tool results, and token usage when the provider reports it. If the rollout cannot be read, the harness falls back to the
codex exec --jsonevents, which omit some tools (such as image views) and mark no call boundaries. Codex records no definitions of the tools it offers, so each step’stoolsstays empty. The final answer and execution status come from those events in aRunResult.
Parameters
Pass harness options with--harness-params '{...}'. The table exposes the installation, provider, and execution behavior that normally needs tuning; path and upload details use built-in defaults.
Parameter reference
| Parameter | Type | Default | Choices / values | Description |
|---|---|---|---|---|
install_strategy | string | install_if_missing | preinstalled / install_if_missing / upload | How to prepare Codex. |
install_command | string | npm install -g @openai/codex | shell command | Command used when Codex is missing. |
setup_capsule_tag | string | unset | node24-v1 | Optional predefined Node toolchain Capsule injected before Codex installation. |
sandbox | string | workspace-write | read-only / workspace-write / danger-full-access | Codex sandbox policy. |
reasoning_effort | string | unset | provider-supported effort | Value written to Codex as model_reasoning_effort. |
max_turns | int | 0 | integer ≥ 0 | Maximum model calls per task; 0 means no limit. Values above 0 need Codex 0.164.0 or later. See Turn limit. |
dangerously_bypass_approvals_and_sandbox | bool | true | true / false | Whether to pass —dangerously-bypass-approvals-and-sandbox. Set it to false only when the Codex approval and sandbox flow must be retained. |
Model API
Codex requires an OpenAI-compatible--model-base-url and --model-api-key, and only supports --model-api-protocol openai-responses (the Responses API). The Codex CLI has dropped Chat Completions support (see openai/codex#7782), so openai-chat is rejected during compatibility validation. The harness appends /v1 when it is absent from the base URL.
Typed Benchmark inputs can register stdio/streamable-http MCP servers in the task Codex configuration and copy a skills directory into its CODEX_HOME/skills. The adapter rejects SSE MCP requirements during planning. Integration does not change official instructions.
Turn limit
Codex has no turn limit of its own. Whenmax_turns is greater than 0, the harness adds a PreModelRequest hook to the session’s Codex configuration, runs Codex with --dangerously-bypass-hook-trust, and ends the process before call max_turns + 1 is sent. This matches the step_limit of mini-SWE-agent: one model call is one turn however many tools it requests, and retries inside a model request are not counted. Reaching the limit records ERROR harness_max_iterations, and the output is still collected and scored.
This requires Codex 0.164.0 or later; older versions fail with an error.
Run examples
- Default
- Custom params
- Runtime Capsule
Run with the default installation and workspace-write policy.
Output
The harness returns aRunResult per task: trajectory, final answer, and execution status. Per-task details and aggregate metrics are written by the benchmark under the run directory (see Results).
Set the task execution deadline through --execution-params with run_timeout_seconds and run_timeout_multiplier. See phase timeouts.