wait_for_all
Blocks execution until all specified agents reach a target state or any agent encounters an error, enabling coordinated parallel agent orchestration with fail-fast behavior.
Instructions
Block until ALL agents reach target state OR any agent errors (fail-fast with partial results).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_ids | Yes | Array of agent IDs | |
| target_state | Yes | State to wait for | |
| timeout_ms | No | Timeout in milliseconds (default: 5 minutes) |
Implementation Reference
- src/agent-engine.ts:517-526 (handler)The core handler logic for the 'wait_for_all' tool in the AgentEngine class.
async waitForAll( agentIds: string[], targetState: AgentState, timeoutMs: number, ): Promise<WaitResult[]> { const results = await Promise.all( agentIds.map((id) => this.waitFor(id, targetState, timeoutMs)), ); return results; } - src/server.ts:747-775 (registration)MCP tool registration for 'wait_for_all' and the adapter function that calls the underlying engine.
// 13. wait_for_all server.tool( "wait_for_all", "Block until ALL agents reach target state OR any agent errors (fail-fast with partial results).", { agent_ids: z.array(z.string()).describe("Array of agent IDs"), target_state: z .enum(["ready", "working", "idle", "done", "error"]) .describe("State to wait for"), timeout_ms: z .number() .int() .positive() .optional() .default(300000) .describe("Timeout in milliseconds (default: 5 minutes)"), }, async (args) => { try { const results = await engine.waitForAll( args.agent_ids, args.target_state, args.timeout_ms, ); return ok({ results }); } catch (e) { return err(e); } },