# Codex Runtime

Duoduo supports two runtime backends:

- **Claude** (default) — Claude Agent SDK.
- **Codex** (GPT) — Codex app-server protocol over stdio.

As of v0.5, Codex is **auto-detected**. No env flag is required. If
`codex` is installed on PATH and the user has run `codex login`, the
daemon advertises `runtime: "codex"` in ManageJob tool schemas and
accepts it in job definitions. Otherwise codex is silently hidden and
any `runtime: "codex"` request falls back to Claude.

## Prerequisites

- `codex` CLI installed and on `$PATH`.
- `codex login` has been run so `codex login status` reports
  "logged in".

Verify with:

```bash
codex --version
codex login status
```

## Environment Variables

| Variable               | Required | Values    | Default           |
| ---------------------- | -------- | --------- | ----------------- |
| `ALADUO_CODEX_SANDBOX` | No       | see below | `workspace-write` |

### Sandbox Modes

| Value                | Disk      | Network | Notes                                         |
| -------------------- | --------- | ------- | --------------------------------------------- |
| `workspace-write`    | cwd only  | No      | Default. Safe for most jobs.                  |
| `read-only`          | Read-only | No      | Analysis-only tasks.                          |
| `danger-full-access` | Full      | Yes     | Needed for localhost API or external network. |

## Refreshing availability after `codex login`

The daemon probes codex availability at boot. If you install codex
or run `codex login` while the daemon is already running, restart
the daemon to re-probe:

```bash
duoduo daemon restart
```

## Usage

When codex is available, the ManageJob tool exposes a `runtime` field
(`"claude"` | `"codex"`). A preflight check runs `codex --version`
at job creation and reports errors early.

## Limitations

- Codex built-in tools (bash, file edit, web search) cannot be selectively disabled.
- `additionalDirectories` not supported — memory board is injected inline.
- `AGENTS.md` is auto-symlinked from `CLAUDE.md` in job workspaces.
- Memory board changes take effect on next thread, not mid-thread.
