# Class LittleGhost::Harnesses::Codex

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/Harnesses/Codex.html

Runs Codex with `codex exec --json`.

In `:isolated` mode Codex's own command sandbox is disabled
(`--sandbox danger-full-access`) because it cannot nest inside an
isolating Sandbox; the LittleGhost Sandbox that runs the harness is the
boundary, and `OPENAI_API_KEY` is the placeholder. In
`:native_guards` mode Codex runs commands in its own sandbox
(`--sandbox workspace-write`) without network access, and
authenticates from the inherited environment, such as `OPENAI_API_KEY` or
`CODEX_API_KEY`.

Approval prompts are disabled in both modes, so a command that needs more
access than Codex's sandbox allows fails instead of asking. The update check
is off, MCP servers are replaced by the request's `mcp_servers`, notification
commands are cleared on the command line, and configuration lives under
`home`. Other settings in a persistent home's `config.toml` still
apply.

`defaults` accepts:

`:base_url`
:   An OpenAI-compatible Responses API base URL, for example a Network::Facade
    address ending in `/v1`. The harness registers it as a model
    provider on the command line.

`:api_key`
:   Placeholder sent as `OPENAI_API_KEY`. A gateway replaces it.

`:model`
:   Model used when the request does not name one.

`:effort`
:   Reasoning effort used when the request does not name one.

Codex reports token usage but not cost, so `budget_usd` cannot stop it. One
`exec` usually completes a single turn that contains every command and edit,
so `max_turns` does not bound its work either; rely on `timeout`.

## Inheritance

`LittleGhost::Harnesses::Codex < LittleGhost::Harnesses::Base`

## Instance methods

<a id="method-i-command"></a>
### `#command`

```ruby
#command(request)
```

Returns the Codex command line for `request`.

<a id="method-i-environment"></a>
### `#environment`

```ruby
#environment(request)
```

Returns Codex's home and, in `:isolated` mode, its credential
placeholder. Codex exits at startup when `CODEX_HOME` does not exist, so it is
the harness home itself, which every run creates.

<a id="method-i-parse_line"></a>
### `#parse_line`

```ruby
#parse_line(line, state)
```

Parses one `exec --json` event.
