Skip to main content
Glama

Execute a task with Codex

codex_execute

Starts a Codex session to execute a task or plan in a workspace, returning session ID, file changes, and commands run. Optionally runs a verification command after execution.

Instructions

Start a new Codex session that executes a plan/task in the given workspace. Returns sessionId (keep it to send review feedback later), agent message, file changes and commands run.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesAbsolute path of the workspace Codex should work in
modelNoCodex model override, e.g. gpt-5.1-codex
promptYesTask or plan for Codex to execute (can embed full plan text)
sandboxNoCodex sandbox policy (default: workspace-write)workspace-write
terminalNoOpen a Terminal window streaming live progress (default: env CODEX_MCP_TERMINAL=1)
timeoutMsNoMax execution time per attempt in ms; auto-resume may add attempts (default: 60 minutes)
writeNotesNoPersist a markdown summary of this run to <cwd>/.codex-flow/notes/<sessionId>.md (default false).
verifyCommandNoAcceptance command the server runs in cwd AFTER the Codex run settles (e.g. the test suite). Its exit code and output tail are returned in `verification` — deterministic evidence, not Codex's claim.
reasoningEffortNoReasoning effort override for the selected model
verifyTimeoutMsNoMax time for verifyCommand in ms (default 10 minutes, cap 30).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffYes
runIdYes
usageYes
errorsYes
statusYes
stderrYes
abortedYes
liveLogYes
acceptedYes
attemptsNo
commandsYes
exitCodeYes
timedOutYes
warningsYes
notesPathYes
sessionIdYes
turnCountYes
redactionsNo
attributionYes
fileChangesYes
parseErrorsYes
agentMessageYes
verificationNo
resumeReasonsNo
sawCompletionYes
schemaVersionYes
unknownEventsYes
reviewFindingsNo
outputTruncatedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed19 schema fields changedv0.25.0
    • addedInput schema / properties / verifyCommand
      Added value: +{
      +  "description": "Acceptance command the server runs in cwd AFTER the Codex run settles (e.g. the test suite). Its exit code and output tail are returned in `verification` — deterministic evidence, not Codex's claim.",
      +  "type": "string"
      +}
    • addedInput schema / properties / verifyTimeoutMs
      Added value: +{
      +  "description": "Max time for verifyCommand in ms (default 10 minutes, cap 30).",
      +  "exclusiveMinimum": 0,
      +  "maximum": 1800000,
      +  "type": "integer"
      +}
    • addedOutput schema / properties / accepted
      Added value: +{
      +  "type": "boolean"
      +}
    • removedOutput schema / properties / agentMessage / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / agentMessage / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / commands / items / properties / exitCode / anyOf
      Removed value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / commands / items / properties / exitCode / type
      Added value: +[
      +  "number",
      +  "null"
      +]
    • removedOutput schema / properties / exitCode / anyOf
      Removed value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / exitCode / type
      Added value: +[
      +  "number",
      +  "null"
      +]
    • removedOutput schema / properties / liveLog / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / liveLog / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / notesPath / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / notesPath / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • addedOutput schema / properties / redactions
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / reviewFindings
      Added value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "dropped": {
      +      "type": "number"
      +    },
      +    "droppedReasons": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "findings": {
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "expected": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "file": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "inScope": {
      +            "type": "boolean"
      +          },
      +          "line": {
      +            "maximum": 9007199254740991,
      +            "minimum": -9007199254740991,
      +            "type": "integer"
      +          },
      +          "observed": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "severity": {
      +            "enum": [
      +              "CRITICAL",
      +              "HIGH",
      +              "MEDIUM",
      +              "LOW"
      +            ],
      +            "type": "string"
      +          },
      +          "summary": {
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "severity",
      +          "file",
      +          "line",
      +          "summary",
      +          "expected",
      +          "observed"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "improvements": {
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "file": {
      +            "type": "string"
      +          },
      +          "id": {
      +            "minLength": 1,
      +            "type": "string"
      +          },
      +          "summary": {
      +            "minLength": 1,
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "id",
      +          "summary"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "outOfScopeCount": {
      +      "maximum": 9007199254740991,
      +      "minimum": 0,
      +      "type": "integer"
      +    },
      +    "parseError": {
      +      "type": "string"
      +    },
      +    "parsed": {
      +      "type": "boolean"
      +    }
      +  },
      +  "required": [
      +    "parsed",
      +    "findings",
      +    "improvements",
      +    "dropped",
      +    "droppedReasons"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / properties / sessionId / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / sessionId / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • addedOutput schema / properties / verification
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "command": {
      +          "type": "string"
      +        },
      +        "durationMs": {
      +          "type": "number"
      +        },
      +        "exitCode": {
      +          "type": [
      +            "number",
      +            "null"
      +          ]
      +        },
      +        "outputTail": {
      +          "type": "string"
      +        },
      +        "passed": {
      +          "type": "boolean"
      +        },
      +        "redactions": {
      +          "type": "number"
      +        },
      +        "skipped": {
      +          "enum": [
      +            "aborted",
      +            "run-failed"
      +          ],
      +          "type": "string"
      +        },
      +        "timedOut": {
      +          "type": "boolean"
      +        }
      +      },
      +      "required": [
      +        "command",
      +        "exitCode",
      +        "timedOut",
      +        "durationMs",
      +        "outputTail",
      +        "passed"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ]
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "sessionId",
      -  "agentMessage",
      -  "fileChanges",
      -  "commands",
      -  "usage",
      -  "errors",
      -  "parseErrors",
      -  "unknownEvents",
      -  "sawCompletion",
      -  "warnings",
      -  "turnCount",
      -  "schemaVersion",
      -  "status",
      -  "runId",
      -  "diff",
      -  "attribution",
      -  "exitCode",
      -  "timedOut",
      -  "aborted",
      -  "outputTruncated",
      -  "stderr",
      -  "liveLog",
      -  "notesPath"
      -]New value: +[
      +  "sessionId",
      +  "agentMessage",
      +  "fileChanges",
      +  "commands",
      +  "usage",
      +  "errors",
      +  "parseErrors",
      +  "unknownEvents",
      +  "sawCompletion",
      +  "warnings",
      +  "turnCount",
      +  "schemaVersion",
      +  "status",
      +  "accepted",
      +  "runId",
      +  "diff",
      +  "attribution",
      +  "exitCode",
      +  "timedOut",
      +  "aborted",
      +  "outputTruncated",
      +  "stderr",
      +  "liveLog",
      +  "notesPath"
      +]
  2. Changed3 schema fields changedv0.13.0
    • addedInput schema / properties / reasoningEffort
      Added value: +{
      +  "description": "Reasoning effort override for the selected model",
      +  "enum": [
      +    "minimal",
      +    "low",
      +    "medium",
      +    "high",
      +    "xhigh"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / timeoutMs / description
      Previous value: -"Max execution time in ms (default: 30 minutes)"New value: +"Max execution time per attempt in ms; auto-resume may add attempts (default: 60 minutes)"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "aborted": {
      +      "type": "boolean"
      +    },
      +    "agentMessage": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "attempts": {
      +      "type": "number"
      +    },
      +    "attribution": {
      +      "anyOf": [
      +        {
      +          "additionalProperties": false,
      +          "properties": {
      +            "files": {
      +              "items": {
      +                "additionalProperties": {},
      +                "properties": {},
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            "untracked": {
      +              "items": {
      +                "additionalProperties": {},
      +                "properties": {},
      +                "type": "object"
      +              },
      +              "type": "array"
      +            }
      +          },
      +          "required": [
      +            "files",
      +            "untracked"
      +          ],
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "commands": {
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "command": {
      +            "type": "string"
      +          },
      +          "exitCode": {
      +            "anyOf": [
      +              {
      +                "type": "number"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          }
      +        },
      +        "required": [
      +          "command",
      +          "exitCode"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "diff": {
      +      "anyOf": [
      +        {
      +          "additionalProperties": false,
      +          "properties": {
      +            "patch": {
      +              "type": "string"
      +            },
      +            "status": {
      +              "type": "string"
      +            },
      +            "statusTruncated": {
      +              "type": "boolean"
      +            },
      +            "truncated": {
      +              "type": "boolean"
      +            }
      +          },
      +          "required": [
      +            "status",
      +            "statusTruncated",
      +            "patch",
      +            "truncated"
      +          ],
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "errors": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "exitCode": {
      +      "anyOf": [
      +        {
      +          "type": "number"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "fileChanges": {
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "kind": {
      +            "type": "string"
      +          },
      +          "path": {
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "path",
      +          "kind"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "liveLog": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "notesPath": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "outputTruncated": {
      +      "type": "boolean"
      +    },
      +    "parseErrors": {
      +      "type": "number"
      +    },
      +    "resumeReasons": {
      +      "items": {
      +        "enum": [
      +          "timeout",
      +          "transient-turn-failure",
      +          "no-completion-marker"
      +        ],
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "runId": {
      +      "type": "string"
      +    },
      +    "sawCompletion": {
      +      "type": "boolean"
      +    },
      +    "schemaVersion": {
      +      "type": "number"
      +    },
      +    "sessionId": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "status": {
      +      "enum": [
      +        "success",
      +        "partial",
      +        "failed",
      +        "aborted"
      +      ],
      +      "type": "string"
      +    },
      +    "stderr": {
      +      "type": "string"
      +    },
      +    "timedOut": {
      +      "type": "boolean"
      +    },
      +    "turnCount": {
      +      "type": "number"
      +    },
      +    "unknownEvents": {
      +      "type": "number"
      +    },
      +    "usage": {
      +      "anyOf": [
      +        {
      +          "additionalProperties": false,
      +          "properties": {
      +            "cachedInputTokens": {
      +              "type": "number"
      +            },
      +            "inputTokens": {
      +              "type": "number"
      +            },
      +            "outputTokens": {
      +              "type": "number"
      +            },
      +            "reasoningOutputTokens": {
      +              "type": "number"
      +            }
      +          },
      +          "required": [
      +            "inputTokens",
      +            "cachedInputTokens",
      +            "outputTokens",
      +            "reasoningOutputTokens"
      +          ],
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ]
      +    },
      +    "warnings": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    }
      +  },
      +  "required": [
      +    "sessionId",
      +    "agentMessage",
      +    "fileChanges",
      +    "commands",
      +    "usage",
      +    "errors",
      +    "parseErrors",
      +    "unknownEvents",
      +    "sawCompletion",
      +    "warnings",
      +    "turnCount",
      +    "schemaVersion",
      +    "status",
      +    "runId",
      +    "diff",
      +    "attribution",
      +    "exitCode",
      +    "timedOut",
      +    "aborted",
      +    "outputTruncated",
      +    "stderr",
      +    "liveLog",
      +    "notesPath"
      +  ],
      +  "type": "object"
      +}
  3. Changed1 schema field changedv0.8.0
    • addedInput schema / properties / writeNotes
      Added value: +{
      +  "description": "Persist a markdown summary of this run to <cwd>/.codex-flow/notes/<sessionId>.md (default false).",
      +  "type": "boolean"
      +}
  4. First observedv0.2.0

TDQS

A3.5/5.0
Behavior2/5

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

There are no annotations, so the description carries the full burden of behavioral disclosure. It mentions that the tool runs a task and returns file changes and commands run, which implies workspace mutation, but it does not state the default sandbox policy, potential side effects, or that this is an execution tool capable of modifying files. This is a significant gap for a code-execution tool.

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?

The description is a single focused sentence that front-loads the primary action, states the workspace scope, and lists meaningful return artifacts. There is no redundant wording or filler.

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

Completeness3/5

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

For a complex 10-parameter execution tool with no annotations, the description is somewhat thin. It explains the core function and key return values, and the output schema covers return structure, but it omits safety-critical context such as the default sandbox being workspace-write and the existence of verification behavior. The description is adequate for basic selection but not fully complete for safe invocation without reading every schema field.

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 the schema already documents all ten parameters. The description does not add deeper parameter semantics, though mentioning sessionId as something to keep for later review provides mild context about the session lifecycle. This matches the baseline for high schema coverage.

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?

The description uses a specific verb and resource: 'Start a new Codex session that executes a plan/task in the given workspace.' It clearly identifies the tool as a session-starter and executor, and the mention of 'new' helps distinguish it from sibling tools like codex_continue. The return values are also summarized, so an agent can tell what to expect.

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

Usage Guidelines3/5

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

The description implies this tool is for starting a fresh execution rather than continuing or reviewing an existing session, but it does not explicitly name alternatives or state when not to use it. Sibling tools like codex_continue and codex_review are not referenced, leaving the agent to infer routing from the word 'new.'

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