---
url: /harnesses/codex.md
---
# Codex

Pandra runs agents on Codex with the login Codex already has:

```sh
pandra run github.com/acme/agents/reviewer --harness codex \
    --prompt "Review the uncommitted changes."
```

How Codex differs from the other harnesses is in the [comparison](/harnesses/choosing.md#how-the-harnesses-differ).

## Login

Pandra reuses Codex's `auth.json`, the model provider your `~/.codex/config.toml` selects, and the `CODEX_ACCESS_TOKEN` and `CODEX_API_KEY` environment variables. A login stored only in the OS keyring is not supported, and Pandra says how to switch.

A [target's credential](/configure/targets.md#target-credentials) can supply a login instead, with the provider `openai`: `--login api-key` writes an OpenAI API key as `CODEX_API_KEY`. Codex has no `subscription` method: a Codex run without a credential uses your ChatGPT login from `codex login`.

A Codex session keeps the provider it started with, so resuming it with another model provider fails with `harness_provider_mismatch`; start a new session instead.

## Settings

Keys of Codex's `config.toml` go under `[harnesses.codex.settings]`, and Pandra adds them to the `config.toml` of the run's prepared home; Pandra refuses the keys it sets itself, with the reason ([harness programs and runners](/configure/targets.md#harness-programs-and-runners)).

## Harness features

A target's `harness-features` lets a run reach these, which are off unless listed ([targets](/configure/targets.md#targets)):

| Feature | Lets the run reach |
| --- | --- |
| `account-connectors` | the apps and connectors of your ChatGPT account |
| `account-plugins` | the plugins of your ChatGPT account, and the plugin marketplace Codex fetches from GitHub |
| `login-shell` | your shell profile, read by a login shell before each command |

## MCP servers

These values stop a run before Codex starts, with `mcp_value_undeliverable`, and `pandra run --dry-run` shows them:

* Two local servers that read one environment variable with different values, or a local server that reads a variable Codex or Pandra uses. Codex gives a local server its values under the names the server reads, and cannot rename them.
* A remote server that connects over SSE, since Codex speaks only stdio and Streamable HTTP. When the server's registry entry offers another method, choose it ([choosing another execution method](/mcp-servers/methods.md#choosing-another-execution-method)).
* A secret header that is empty or only whitespace, which Codex would leave out without a message.

## Isolation from the project

A run on Codex leaves out what Codex itself would load from the workspace and your home:

* `AGENTS.md` files, unless you add them as [Instructions](#instructions) says.
* The workspace's `.codex/` configuration, hooks, and rules, because the run treats the workspace as untrusted.
* The skills in the workspace's `.agents/skills` and `.codex/skills`, and in your `~/.agents/skills`. To give runs your own skills, [let the harness load the skills in ~/.agents/skills](/configure/instructions-and-skills.md#let-the-harness-load-the-skills-in-agentsskills). A skill that the agent adds to the workspace during the run is not left out.

## Instructions

When you [add the instructions your harness reads](/configure/instructions-and-skills.md#add-the-instructions-your-harness-reads), a Codex run gets these files:

* `home`: `AGENTS.override.md`, else `AGENTS.md`, in `~/.codex`, or in `$CODEX_HOME`.
* `repo`, in each directory from the repository's root down to the workspace: `AGENTS.override.md`, else `AGENTS.md`.

Codex's own instructions already tell the agent to load a skill whose description matches its task, so a Codex run leaves out the [`skill-guide`](/configure/instructions-and-skills.md#have-the-agent-load-matching-skills) source, and its dry run says `not supported by codex`.

With `instructions-mode = "replace"` ([settings of one agent](/configure/agent-settings.md#settings-of-one-agent)), the agent's instructions take the place of Codex's base instructions; its instructions on its sandbox and approvals stay.

A resumed conversation keeps the instructions of its first launch until Codex compacts it, so an edit to an instructions file reaches it only after a compaction. With `instructions-mode = "replace"`, the edit reaches it at the resume.

## Permissions

Runs use Codex's automatic review, which covers only requests to leave Codex's sandbox; commands inside the sandbox run without review ([permissions](/harnesses/permissions.md)).

On Linux, Codex's sandbox refuses what a nested `pandra run`, `resume`, `guild run`, `quest run`, or `session send` needs. The command fails, with `harness_sandboxed`, or for `session send` with `io_error` and `cannot reach the run's owner`, and the agent runs it again with the sandbox escalation Codex offers. Without an escalation, as in `read-only`, the command is yours to run outside the sandbox. Pandra never widens the sandbox itself.

## Run Pandra from your own Codex

Your own Codex sandboxes a `pandra` command the same way. In Codex's interface, the agent can ask you to approve running the command outside the sandbox. `codex exec` asks nothing, so for a task that runs Pandra agents, use `--sandbox danger-full-access`:

```sh
codex exec --sandbox danger-full-access "Review the uncommitted changes with the reviewer agent."
```

Every command the agent runs in that task, not only `pandra`, then runs outside Codex's sandbox, with your file access and the network.
