> ## Documentation Index
> Fetch the complete documentation index at: https://agent-compass.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex

The `codex` harness runs the [OpenAI Codex CLI](https://github.com/openai/codex) 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

<table>
  <thead>
    <tr><th>Parameter</th><th>Type</th><th>Default</th><th>Choices / values</th><th>Description</th></tr>
  </thead>

  <tbody>
    <tr><td>`install_strategy`</td><td>string</td><td>`install_if_missing`</td><td>`preinstalled` / `install_if_missing` / `upload`</td><td>How to prepare Codex.</td></tr>
    <tr><td>`install_command`</td><td>string</td><td>`npm install -g @openai/codex`</td><td>shell command</td><td>Command used when Codex is missing.</td></tr>
    <tr><td>`setup_capsule_tag`</td><td>string</td><td>unset</td><td>`node24-v1`</td><td>Optional predefined Node toolchain Capsule injected before Codex installation.</td></tr>
    <tr><td>`sandbox`</td><td>string</td><td>`workspace-write`</td><td>`read-only` / `workspace-write` / `danger-full-access`</td><td>Codex sandbox policy.</td></tr>
    <tr><td>`reasoning_effort`</td><td>string</td><td>unset</td><td>provider-supported effort</td><td>Value written to Codex as `model_reasoning_effort`.</td></tr>
    <tr><td>`max_turns`</td><td>int</td><td>`0`</td><td>integer ≥ 0</td><td>Maximum model calls per task; `0` means no limit. Values above `0` need Codex 0.164.0 or later. See [Turn limit](#turn-limit).</td></tr>
    <tr><td>`dangerously_bypass_approvals_and_sandbox`</td><td>bool</td><td>`true`</td><td>`true` / `false`</td><td>Whether to pass `--dangerously-bypass-approvals-and-sandbox`. Set it to `false` only when the Codex approval and sandbox flow must be retained.</td></tr>
  </tbody>
</table>

### 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](https://github.com/openai/codex/discussions/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](https://agent-compass.mintlify.site/en/user_guide/modules/harnesses/mini_swe_agent.md): 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

> [tab] Default
>
> Run with the default installation and workspace-write policy.
>
> ```bash theme={"system"}
> agentcompass run \
>   swebench_verified \
>   codex \
>   "$MODEL_NAME" \
>   --env docker \
>   --model-base-url "$MODEL_BASE_URL" \
>   --model-api-key "$MODEL_API_KEY" \
>   --model-api-protocol openai-responses
> ```

> [tab] Custom params
>
> Adjust the sandbox policy.
>
> ```bash theme={"system"}
> agentcompass run \
>   swebench_verified \
>   codex \
>   "$MODEL_NAME" \
>   --env docker \
>   --harness-params '{"sandbox":"workspace-write"}' \
>   --model-base-url "$MODEL_BASE_URL" \
>   --model-api-key "$MODEL_API_KEY" \
>   --model-api-protocol openai-responses
> ```

> [tab] Runtime Capsule
>
> Use a `node24` Capsule in an Environment without compatible Node, npm, or glibc.
>
> ```bash theme={"system"}
> agentcompass run \
>   swebench_verified \
>   codex \
>   "$MODEL_NAME" \
>   --env docker \
>   --harness-params '{
>     "install_strategy": "install_if_missing",
>     "install_command": "npm install -g @openai/codex@<version>",
>     "setup_capsule_tag": "node24-v1"
>   }' \
>   --model-base-url "$MODEL_BASE_URL" \
>   --model-api-key "$MODEL_API_KEY" \
>   --model-api-protocol openai-responses
> ```

## 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](https://agent-compass.mintlify.site/en/user_guide/other_features/results/overview.md#directory-layout) (see [Results](https://agent-compass.mintlify.site/en/user_guide/other_features/results/overview.md)).

Set the task execution deadline through `--execution-params` with `run_timeout_seconds` and `run_timeout_multiplier`. See [phase timeouts](https://agent-compass.mintlify.site/en/user_guide/using_agentcompass/timeouts.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.