codex_run
Run Codex CLI tasks or resume existing sessions by session_id, returning progress, background task IDs, and session permissions for agent orchestration.
Instructions
Run Codex CLI (Executor) on a task or continue an existing Codex session via session_id. Inherits ~/.codex/config.toml (model, reasoning effort, custom provider, auth, MCPs, plugins, notify), disables unbounded_connection_retries, and applies a best-effort reset-card prompt guard (opt out via CODEX_DISABLE_RESET_CARD_GUARD=1 or true). Defaults for new runs: model=(inherited from ~/.codex/config.toml), reasoning_effort=(inherited from ~/.codex/config.toml), sandbox="workspace-write", wait_seconds=300. When session_id is provided and sandbox is omitted, saved session permissions are preserved instead of reapplying CODEX_DEFAULT_SANDBOX. Progress notifications are emitted every 15s when the client supplies a progressToken. If execution exceeds wait_seconds, returns status="running" with task_id so you can call codex_wait / codex_status / codex_cancel. If status="rate_limited", STOP immediately and ask the user; never retry or trigger a reset card.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt": "<prompt>",
"cwd": "<cwd>"
},
"name": "codex_run"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | Absolute path of the working directory where Codex should execute. | |
| model | No | Optional model override. Omit to inherit the model configured in ~/.codex/config.toml. | |
| images | No | Optional local image file paths attached via -i. | |
| prompt | Yes | Clear, self-contained instructions for the Codex CLI executor. | |
| sandbox | No | Defaults to "workspace-write" (via CODEX_DEFAULT_SANDBOX) for new runs; omitted on resume to preserve saved session permissions unless explicitly set. | |
| add_dirs | No | Additional writable directories passed via --add-dir (only applies to new exec sessions). | |
| worktree | No | If true, passes --worktree to run Codex in a new managed Git worktree. | |
| session_id | No | Optional Codex session_id returned from an earlier codex_run call to continue that conversation via `codex exec resume`. | |
| wait_seconds | No | Seconds to wait synchronously before returning a background task_id. Default: 300. Pass 0 to return immediately. | |
| reasoning_effort | No | Optional reasoning effort override (e.g. low, medium, high, xhigh, max). Omit to inherit ~/.codex/config.toml. | |
| skip_git_repo_check | No | Defaults to true so Codex can run cleanly even outside a Git repository. |