Skip to main content
Glama

Run multiple Codex tasks in parallel across workspaces

codex_batch

Run multiple coding tasks in parallel across separate workspaces with a configurable concurrency limit. Each task uses its own directory lock and returns results in the original input order.

Instructions

Fan out N tasks across N cwds (typically git worktrees) with a bounded concurrency limit. Each task uses its own per-cwd lock, so callers must supply distinct cwds. Returns one result entry per input task in input order.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tasksYesTasks to run in parallel, one per workspace. Each task uses its own cwd (must be unique in the batch).
failFastNoIf true, cancel remaining tasks on the first failure. Default false (continue-on-error).
maxConcurrencyNoCap on parallel tasks (default 10, hard cap 32).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
tasksYes
totalYes
failedYes
summaryYes
redactionsTotalNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed12 schema fields changedv0.25.0
    • addedOutput schema / properties / redactionsTotal
      Added value: +{
      +  "type": "number"
      +}
    • removedOutput schema / properties / tasks / items / properties / exitCode / anyOf
      Removed value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / tasks / items / properties / exitCode / type
      Added value: +[
      +  "number",
      +  "null"
      +]
    • removedOutput schema / properties / tasks / items / properties / liveLog / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / tasks / items / properties / liveLog / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / tasks / items / properties / parsed / properties / agentMessage / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / tasks / items / properties / parsed / properties / agentMessage / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / tasks / items / properties / parsed / properties / commands / items / properties / exitCode / anyOf
      Removed value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / tasks / items / properties / parsed / properties / commands / items / properties / exitCode / type
      Added value: +[
      +  "number",
      +  "null"
      +]
    • removedOutput schema / properties / tasks / items / properties / parsed / properties / sessionId / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / tasks / items / properties / parsed / properties / sessionId / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • addedOutput schema / properties / tasks / items / properties / redactions
      Added value: +{
      +  "type": "number"
      +}
  2. Addedv0.16.0
  3. Removedv0.15.1
  4. Changed3 schema fields changedv0.13.0
    • addedInput schema / properties / tasks / items / properties / reasoningEffort
      Added value: +{
      +  "description": "Reasoning effort override for the selected model",
      +  "enum": [
      +    "minimal",
      +    "low",
      +    "medium",
      +    "high",
      +    "xhigh"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / tasks / items / properties / timeoutMs / description
      Added 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": {
      +    "failed": {
      +      "type": "number"
      +    },
      +    "summary": {
      +      "additionalProperties": false,
      +      "properties": {
      +        "aborted": {
      +          "type": "number"
      +        },
      +        "failed": {
      +          "type": "number"
      +        },
      +        "partial": {
      +          "type": "number"
      +        },
      +        "succeeded": {
      +          "type": "number"
      +        },
      +        "total": {
      +          "type": "number"
      +        }
      +      },
      +      "required": [
      +        "total",
      +        "succeeded",
      +        "failed",
      +        "aborted",
      +        "partial"
      +      ],
      +      "type": "object"
      +    },
      +    "tasks": {
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "aborted": {
      +            "type": "boolean"
      +          },
      +          "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"
      +              }
      +            ]
      +          },
      +          "cwd": {
      +            "type": "string"
      +          },
      +          "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"
      +              }
      +            ]
      +          },
      +          "error": {
      +            "type": "string"
      +          },
      +          "exitCode": {
      +            "anyOf": [
      +              {
      +                "type": "number"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          },
      +          "isError": {
      +            "type": "boolean"
      +          },
      +          "liveLog": {
      +            "anyOf": [
      +              {
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          },
      +          "outputTruncated": {
      +            "type": "boolean"
      +          },
      +          "parsed": {
      +            "additionalProperties": false,
      +            "properties": {
      +              "agentMessage": {
      +                "anyOf": [
      +                  {
      +                    "type": "string"
      +                  },
      +                  {
      +                    "type": "null"
      +                  }
      +                ]
      +              },
      +              "commands": {
      +                "items": {
      +                  "additionalProperties": false,
      +                  "properties": {
      +                    "command": {
      +                      "type": "string"
      +                    },
      +                    "exitCode": {
      +                      "anyOf": [
      +                        {
      +                          "type": "number"
      +                        },
      +                        {
      +                          "type": "null"
      +                        }
      +                      ]
      +                    }
      +                  },
      +                  "required": [
      +                    "command",
      +                    "exitCode"
      +                  ],
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              },
      +              "errors": {
      +                "items": {
      +                  "type": "string"
      +                },
      +                "type": "array"
      +              },
      +              "fileChanges": {
      +                "items": {
      +                  "additionalProperties": false,
      +                  "properties": {
      +                    "kind": {
      +                      "type": "string"
      +                    },
      +                    "path": {
      +                      "type": "string"
      +                    }
      +                  },
      +                  "required": [
      +                    "path",
      +                    "kind"
      +                  ],
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              },
      +              "parseErrors": {
      +                "type": "number"
      +              },
      +              "sawCompletion": {
      +                "type": "boolean"
      +              },
      +              "sessionId": {
      +                "anyOf": [
      +                  {
      +                    "type": "string"
      +                  },
      +                  {
      +                    "type": "null"
      +                  }
      +                ]
      +              },
      +              "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"
      +            ],
      +            "type": "object"
      +          },
      +          "resumeReasons": {
      +            "items": {
      +              "enum": [
      +                "timeout",
      +                "transient-turn-failure",
      +                "no-completion-marker"
      +              ],
      +              "type": "string"
      +            },
      +            "type": "array"
      +          },
      +          "runId": {
      +            "type": "string"
      +          },
      +          "schemaVersion": {
      +            "type": "number"
      +          },
      +          "status": {
      +            "enum": [
      +              "success",
      +              "partial",
      +              "failed",
      +              "aborted"
      +            ],
      +            "type": "string"
      +          },
      +          "stderr": {
      +            "type": "string"
      +          },
      +          "taskIndex": {
      +            "type": "number"
      +          },
      +          "timedOut": {
      +            "type": "boolean"
      +          }
      +        },
      +        "required": [
      +          "taskIndex",
      +          "cwd",
      +          "schemaVersion",
      +          "status",
      +          "parsed",
      +          "diff",
      +          "exitCode",
      +          "timedOut",
      +          "aborted",
      +          "stderr",
      +          "liveLog",
      +          "isError"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "total": {
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "tasks",
      +    "total",
      +    "failed",
      +    "summary"
      +  ],
      +  "type": "object"
      +}
  5. Addedv0.8.0

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It discloses per-cwd locking, the need for distinct cwds, bounded parallelism, and ordered result entries. It does not detail failure behavior or auth requirements, but the core behavioral traits are well covered beyond what the schema shows.

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?

Three sentences with no filler. The opening sentence states the core operation and scope, the second adds the critical locking constraint, and the third clarifies the return shape. Every sentence earns its place.

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 moderately complex batched tool, the description is complete: it explains parallelism, the workspace requirement, the uniqueness constraint, and the result ordering. The parameter schema covers the remaining details like defaults, limits, and timeouts, and an output schema exists, so return structure does not need to be restated.

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 the schema already documents tasks, failFast, and maxConcurrency. The description adds meaningful semantic context beyond the schema: distinct cwds are required because each task holds its own per-cwd lock, results are returned in input order, and parallelism is bounded. This helps an agent choose and fill parameters correctly.

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 clearly states the tool fans out N tasks across N cwds in parallel, which is specific and distinct from the sibling tools that focus on single sessions or execution. It also names the resource (Codex tasks across workspaces) and includes the unique per-cwd lock requirement, so an agent can distinguish it from codex_execute or codex_sessions.

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?

The description gives clear context for when to use this tool: multiple tasks, multiple cwds, typically git worktrees, with a bounded concurrency limit. It also states a hard prerequisite (distinct cwds). However, it does not explicitly name alternatives or state when not to use the batch tool, so it stops short of full exclusion guidance.

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