Run a Codex task
codex_runDelegate a coding task to OpenAI Codex, starting or resuming a thread; it waits, then returns status, the agent's message, changed files, and commands run.
Instructions
Give Codex (OpenAI coding agent) a task. Starts a new thread, or continues an existing one when thread_id is given. Blocks up to wait_seconds, then returns status, Codex's latest message, files changed and commands run. status "inProgress" → codex_wait; "waitingForInput" → answer pending_requests with codex_respond. Run several threads in parallel by calling codex_run with wait_seconds: 0 for each, then codex_wait with all thread_ids. Review Codex's changes yourself before reporting them as done.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Absolute working directory. Required for a new thread. | |
| model | No | Model override (see codex_models). Defaults to Codex config. | |
| effort | No | Reasoning effort override, e.g. low | medium | high | xhigh (see codex_models). | |
| prompt | Yes | Instructions for Codex. Be specific: goal, files, constraints, what "done" looks like. | |
| sandbox | No | Sandbox for a new (or resumed) thread; fixed after that. Default: workspace-write. | |
| approval | No | When Codex must ask before acting; can change between turns. "never" auto-approves everything. Default: on-request. | |
| worktree | No | New thread only: run in a fresh git worktree + branch (codex/<stamp>) of cwd's repo, so parallel tasks never collide. The worktree is kept for you to inspect/merge. | |
| thread_id | No | Continue this existing Codex thread (keeps its context). | |
| web_search | No | New thread only: enable live web search for Codex. | |
| wait_seconds | No | Seconds to block before returning a progress snapshot (default 240). Returns early when the turn finishes or Codex needs an answer. The turn keeps running after this returns. | |
| output_schema | No | JSON Schema the final message must follow (structured output). |