Skip to main content
Glama

Run a Codex task

codex_run

Delegates a coding task to OpenAI Codex by starting a new thread or continuing an existing one, then returns status, latest message, changed files, diff preview, 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, diff preview, 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 (prefer worktree: true), then codex_wait with all thread_ids. Verify Codex's diff/changes before reporting them as done.

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>"
    },
    "name": "codex_run"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoAbsolute working directory. Required for a new thread.
modelNoModel override (see codex_models). Defaults to Codex config.
effortNoReasoning effort override, e.g. low | medium | high | xhigh (see codex_models).
imagesNoOptional local image file paths to attach to this turn.
promptYesInstructions for Codex. Be specific: goal, files, constraints, verification, and what "done" looks like.
sandboxNoSandbox for a new (or resumed) thread; fixed after that. Default: workspace-write.
approvalNoWhen Codex must ask before acting; can change between turns. "never" auto-approves everything. Default: on-request.
worktreeNoNew thread only: run in an isolated git worktree + branch (codex/<stamp>) created from cwd's HEAD. Note: uncommitted parent changes are not copied into a new worktree.
thread_idNoContinue this existing Codex thread (keeps its context).
web_searchNoNew thread only: enable live web search for Codex.
wait_secondsNoSeconds to block before returning a progress snapshot (default 120). Returns early when the turn finishes or Codex needs an answer. The turn keeps running after this returns.
output_schemaNoJSON Schema the final message must follow (structured output).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses blocking semantics and the wait_seconds budget, that the turn keeps running after the snapshot returns, that what comes back includes status, latest message, changed files, diff preview, and commands run. It omits that this mutates the repository by default (workspace-write) and says nothing about cost or failure modes, so it stops short of fully covering the risk profile of an autonomous coding agent.

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?

Five short sentences, front-loaded with purpose, then return payload, then status routing, then the parallel pattern, then a verification reminder. No filler, and each sentence changes what the agent would do next.

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

Completeness5/5

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

For a 12-parameter, no-output-schema tool, the description compensates by enumerating the return payload and the state machine that governs follow-up calls. An agent has enough to make a first call and to handle either non-terminal status correctly.

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

Parameters3/5

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

Schema description coverage is 100%, so every parameter (including sandbox, approval, worktree, and output_schema) is already documented inline; the baseline is 3. The description reinforces thread_id continuation and the wait_seconds: 0 parallel pattern, but adds little semantics that the schema does not already supply.

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 ('Give Codex (OpenAI coding agent) a task') and immediately clarifies the two modes: a new thread vs. continuing one when thread_id is given. That scope distinction is enough to separate it from codex_respond, codex_wait, and codex_steer without opening any schema.

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

Usage Guidelines5/5

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

Explicit routing rules are given for both terminal states: 'inProgress' → codex_wait and 'waitingForInput' → answer pending_requests with codex_respond. It also names a concrete alternative workflow (fire many threads with wait_seconds: 0, preferably worktree: true, then codex_wait with all thread_ids) and adds a verification caveat before reporting done.

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