Skip to main content
Glama

Spawn worker pool

spawn_workers

Spawn a pool of queue workers to claim and run tasks from a named queue in parallel panes until the queue drains, with optional git worktree isolation and per-worker account rotation.

Instructions

Spawn a pool of queue workers in one call (#6). Worker panes open beside the caller (in the calling pane's tab) unless tabId, projectTab or windowId says otherwise. Opens pane(s) running the native hyperpanes worker runner bound to queue: it claims tasks and runs command (via sh -c, so $HP_TASK_PAYLOAD / $HP_TASK_ID / $HP_FENCING_TOKEN / $HP_QUEUE are in the environment) for each, acking on exit 0 and nacking on non-zero, until the queue drains — then the pane exits. count = how many competing workers; by default each gets ITS OWN pane (layout:"pane-per-worker") so you can watch one agent per pane — pass layout:"single-pane" for the legacy one-pane-runs-N behaviour. isolation:"worktree" runs each task in a throwaway git worktree that auto-removes (needs cwd to be a git repo) and REQUIRES base — the explicit committish each task worktree forks from, passed to the runner as --base (the call fails without it). stream:true renders a Claude child's --output-format stream-json events as readable progress instead of the silence a bare claude -p gives you; logDir tees each task's raw output to a file that outlives the pane; lingerSecs keeps the pane open after the queue drains. The runner binary defaults to hyperpanes on PATH (override with HYPERPANES_WORKER_BIN on the bridge). env/accounts/meta/project/subtitle pass through to each worker pane spec — merge order: env is the shared base, accounts[i % len] sets each pane's CLAUDE_CONFIG_DIR and wins over env (rotation requires layout:"pane-per-worker" when count > 1; single-pane shares one process env, so the call fails loudly). Every worker pane is stamped with default org meta role="worker", task="queue:", parent=<this bridge's pane> (so worker send_to_parent works out of the box); caller meta wins over those defaults. Returns the spawned pane ids.

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": {
      "queue": "<queue>",
      "command": "<command>"
    },
    "name": "spawn_workers"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNorunner working directory; required (a git repo) for isolation:"worktree"
envNoenv vars set on every worker pane
baseNofork point committish for isolation:"worktree" task worktrees (REQUIRED with it): "main" for independent work, the goal's integration branch for a dependent wave
metaNofree-form org metadata merged OVER the stamped defaults (role="worker", task="queue:<queue>", parent=<this bridge's HYPERPANES_PANE_ID>) — an explicit key always wins
colorNo
countNocompeting workers (default 1); one pane each unless layout:"single-pane"
queueYesthe work queue to drain
tabIdNoopen the pane directly in this existing tab (a tabId from list_panes) instead of the caller's tab (or, with only `windowId`, that window's active tab) — nothing opens elsewhere first, so never open_pane then move_pane. Exclusive with projectTab; `windowId` is optional and must match the tab's window. Needs a hyperpanes app with newPane `tabId` support; an older app opens it in the active tab and the result carries a `warning`
layoutNo"pane-per-worker" (default) = one visible pane per worker; "single-pane" = one runner pane multiplexing all N
logDirNotee each task's raw output to <dir>/<queue>-<taskId>.log, so the transcript survives the pane closing
streamNorender the child's Claude stream-json events as readable progress (pair with `--output-format stream-json --verbose` in `command`)
commandYesshell command run per claimed task; reads the task from $HP_TASK_PAYLOAD etc.
projectNoopen worker panes in a remembered project (see list_projects): defaults cwd + color from it
accountsNoCLAUDE_CONFIG_DIR account rotation: under layout:"pane-per-worker" (default), worker pane i gets env.CLAUDE_CONFIG_DIR = accounts[i % accounts.length], winning over env.CLAUDE_CONFIG_DIR. Rotation needs one pane per worker: with layout:"single-pane" and count > 1 the call FAILS (one process env cannot rotate per-worker); single-pane with count 1 gets accounts[0]
subtitleNosecondary header line set on every worker pane
windowIdNo
isolationNo"worktree" = run each task in a throwaway git worktree (default "none"); requires `base`
lingerSecsNohold each worker pane open this many seconds after the queue drains (default 0 = close immediately)
projectTabNowith `project`: open the pane in that project's tab (reused if the window has one, else created with the project's name and colour) instead of the caller's tab. Opt-in; needs a hyperpanes app with `projectTab` support

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.1.25
    • addedInput schema / properties / projectTab
      Added value: +{
      +  "description": "with `project`: open the pane in that project's tab (reused if the window has one, else created with the project's name and colour) instead of the caller's tab. Opt-in; needs a hyperpanes app with `projectTab` support",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / tabId
      Added value: +{
      +  "description": "open the pane directly in this existing tab (a tabId from list_panes) instead of the caller's tab (or, with only `windowId`, that window's active tab) — nothing opens elsewhere first, so never open_pane then move_pane. Exclusive with projectTab; `windowId` is optional and must match the tab's window. Needs a hyperpanes app with newPane `tabId` support; an older app opens it in the active tab and the result carries a `warning`",
      +  "type": "string"
      +}
  2. First observedv0.1.13

TDQS

A4.5/5.0
Behavior5/5

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

With no annotations supplied, the description carries the whole load and does so thoroughly: it discloses the task lifecycle (claim, run `command` via `sh -c` with the HP_* env vars, ack on exit 0, nack on non-zero, drain then pane exit), the failure conditions (missing `base`, single-pane rotation with count > 1), the persistence semantics of logDir and lingerSecs, the meta stamping defaults, and the return value (spawned pane ids). That is everything an agent needs to predict what happens on invocation.

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

Conciseness4/5

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

The critical information is front-loaded: what it spawns, then where panes open, then runner semantics, then per-parameter modifiers, then the return value. Every sentence carries operational detail, but it is delivered as one dense, unstructured block with heavy parenthetical and backtick use, which makes scanning harder than it needs to be.

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 19-parameter tool with no annotations and no output schema, the description covers the lifecycle, the pane-placement model, the failure modes and the return value. The remaining gaps are minor parameters (`color`, `windowId`, `subtitle`) that the schema leaves undescribed and the prose does not rescue.

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 already 89%, so most parameters are self-describing; the description adds real meaning on top with the env/accounts/meta merge order, the default meta stamping (role=worker, task=queue:<queue>, parent=this bridge's pane) and the rotation rule tied to layout. A few parameters (`color`, `windowId`, `subtitle`, `projectTab` interaction) get no prose treatment, so it is not exhaustive.

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 opening sentence pairs a specific verb with a specific resource ('Spawn a pool of queue workers in one call') and immediately explains that it opens panes running the native `hyperpanes worker` runner bound to a queue. That makes it easy to distinguish from siblings like open_pane or enqueue_task, which only create a pane or a task rather than a draining worker pool.

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 states the calling context and the constraints that steer the decision: default pane-per-worker layout for observability, single-pane for legacy behaviour, isolation:worktree requiring a git repo plus `base`, and rotation requiring pane-per-worker or failing loudly. It never names a sibling alternative or an explicit 'use that instead' case, so an agent has to infer the boundary from the queue semantics alone.

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