Skip to main content
Glama

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

NameRequiredDescriptionDefault
cwdYesAbsolute path of the working directory where Codex should execute.
modelNoOptional model override. Omit to inherit the model configured in ~/.codex/config.toml.
imagesNoOptional local image file paths attached via -i.
promptYesClear, self-contained instructions for the Codex CLI executor.
sandboxNoDefaults to "workspace-write" (via CODEX_DEFAULT_SANDBOX) for new runs; omitted on resume to preserve saved session permissions unless explicitly set.
add_dirsNoAdditional writable directories passed via --add-dir (only applies to new exec sessions).
worktreeNoIf true, passes --worktree to run Codex in a new managed Git worktree.
session_idNoOptional Codex session_id returned from an earlier codex_run call to continue that conversation via `codex exec resume`.
wait_secondsNoSeconds to wait synchronously before returning a background task_id. Default: 300. Pass 0 to return immediately.
reasoning_effortNoOptional reasoning effort override (e.g. low, medium, high, xhigh, max). Omit to inherit ~/.codex/config.toml.
skip_git_repo_checkNoDefaults to true so Codex can run cleanly even outside a Git repository.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden and does: it discloses config inheritance from ~/.codex/config.toml, that unbounded_connection_retries is disabled, a reset-card prompt guard with an env-var opt-out, sandbox default of workspace-write, progress notification cadence (15s, requires progressToken), and the timeout-to-task_id fallback. The rate_limited stop-and-ask rule and the note that omitted sandbox on resume preserves saved session permissions are exactly the non-obvious traits an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Dense but front-loaded: mode of operation first, then inherited behavior, then defaults, then the async/error contract. Every sentence carries operational information; the parenthetical config list is compact and earns its space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 11-parameter execution tool with no output schema, the description covers the async return contract (status="running" plus task_id) and the rate_limited state, which is the critical part. It stops short of describing what a successful completion returns (e.g., final assistant output), leaving one small gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds real meaning: model and reasoning_effort inherit unless overridden, sandbox omission behaves differently on new runs versus resumes, and wait_seconds governs whether the call returns a task_id. The interaction between wait_seconds and the returned status is semantic glue the schema alone does not express.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Run Codex CLI (Executor) on a task') plus the two operating modes: fresh run versus resuming an existing session via session_id. That new-vs-resume distinction is the key way this differs from siblings like codex_wait or codex_steer, and it's stated up front.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly routes the agent on continuation (use session_id to resume) and on async handling ('call codex_wait / codex_status / codex_cancel' when status="running"), and gives a hard stop rule for rate_limited. It does not cover when to prefer this over codex_review or codex_steer, so guidance is strong but not exhaustive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.