Skip to main content
The 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 codex is absent, the harness then applies install_strategy and install_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 --json events, 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’s tools stays empty. The final answer and execution status come from those events in a RunResult.

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

ParameterTypeDefaultChoices / valuesDescription
install_strategystringinstall_if_missingpreinstalled / install_if_missing / uploadHow to prepare Codex.
install_commandstringnpm install -g @openai/codexshell commandCommand used when Codex is missing.
setup_capsule_tagstringunsetnode24-v1Optional predefined Node toolchain Capsule injected before Codex installation.
sandboxstringworkspace-writeread-only / workspace-write / danger-full-accessCodex sandbox policy.
reasoning_effortstringunsetprovider-supported effortValue written to Codex as model_reasoning_effort.
max_turnsint0integer ≥ 0Maximum 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_sandboxbooltruetrue / falseWhether 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. When max_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

Run with the default installation and workspace-write policy.

Output

The harness returns a RunResult 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.