Skip to main content
Glama

Run multiple Codex tasks in parallel across workspaces

codex_batch

Run multiple coding tasks in parallel across distinct working directories or git worktrees, with bounded concurrency and one ordered result per task.

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.

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": {
      "tasks": "<tasks>"
    },
    "name": "codex_batch"
  }
}

Input 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

NameRequiredDescriptionDefault
tasksYes
totalYes
failedYes
summaryYes
redactionsTotalNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.38.0
    • changedOutput schema / properties / tasks / items / properties / attribution / anyOf
      Previous value: -[
      -  {
      -    "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"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "files": {
      +        "items": {
      +          "additionalProperties": {},
      +          "properties": {},
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "reason": {
      +        "type": "string"
      +      },
      +      "unavailable": {
      +        "type": "boolean"
      +      },
      +      "untracked": {
      +        "items": {
      +          "additionalProperties": {},
      +          "properties": {},
      +          "type": "object"
      +        },
      +        "type": "array"
      +      }
      +    },
      +    "required": [
      +      "files",
      +      "untracked"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedOutput schema / properties / tasks / items / properties / diff / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "patch": {
      -        "type": "string"
      -      },
      -      "status": {
      -        "type": "string"
      -      },
      -      "statusTruncated": {
      -        "type": "boolean"
      -      },
      -      "truncated": {
      -        "type": "boolean"
      -      }
      -    },
      -    "required": [
      -      "status",
      -      "statusTruncated",
      -      "patch",
      -      "truncated"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "patch": {
      +        "type": "string"
      +      },
      +      "reason": {
      +        "type": "string"
      +      },
      +      "status": {
      +        "type": "string"
      +      },
      +      "statusTruncated": {
      +        "type": "boolean"
      +      },
      +      "truncated": {
      +        "type": "boolean"
      +      },
      +      "unavailable": {
      +        "type": "boolean"
      +      }
      +    },
      +    "required": [
      +      "status",
      +      "statusTruncated",
      +      "patch",
      +      "truncated"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  2. 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"
      +}
  3. Addedv0.16.0
  4. Removedv0.15.1
  5. 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"
      +}
  6. Addedv0.8.0

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations at all, the description carries the full burden and does disclose genuinely non-obvious behavior: per-cwd locking, a bounded concurrency limit, and results returned one-per-task in input order. It does not describe what partial failure looks like at the description level (that the default continues on error is only in the schema's failFast field), which keeps it out of 5 territory.

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 short sentences, zero filler, with the concurrency/parallelism model front-loaded and the locking precondition immediately after. The return-order guarantee lands last where it belongs.

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 a complex batched-execution tool with an output schema, the key operational facts an agent needs (unique cwds, concurrency bound, ordered results) are present, and parameters/returns are fully covered by structured fields. The remaining gap is routing guidance relative to the single-task sibling, which is not covered anywhere else.

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%, including the uniqueness rule on cwd, the concurrency cap, and the failFast semantics, so the schema already does the heavy lifting. The description restates the distinct-cwd requirement and the concurrency bound but adds no syntax, defaults, or constraints beyond that, matching the baseline 3.

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

Purpose4/5

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

"Fan out N tasks across N cwds (typically git worktrees) with a bounded concurrency limit" gives a specific verb, resource, and execution model, which is enough to distinguish this batch tool from a single-task sibling like codex_execute. It stops short of naming an alternative explicitly, so a 4 rather than a 5.

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?

It establishes the operating context (typically git worktrees) and a hard precondition ("callers must supply distinct cwds"), which implies when this tool is appropriate. It never states when to use it instead of running codex_execute repeatedly, nor when to prefer smaller batches, so usage guidance is only implied.

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