Skip to main content
Glama

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
NameRequiredDescriptionDefault
agent_idsYesArray of agent IDs
target_stateYesState to wait for
timeout_msNoTimeout in milliseconds (default: 5 minutes)

Implementation Reference

  • 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);
        }
      },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/EtanHey/cmuxlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server