Skip to content

wait_agent

Wait for one or more orchestration agents to satisfy a condition.

Package: @agentrail/capabilities (orchestration)

This tool is available only when the multi-agent orchestration capability is enabled.

Parameters

NameTypeRequiredDescription
idstringYesUnique wait-condition ID chosen by the orchestrator.
agentIdstringYesPrimary orchestration agent ID to wait on.
agentIdsstring[]NoOptional set of additional agent IDs to include in the wait.
kindstringYesCondition kind: "agent-closed" or "agent-idle".
descriptionstringYesHuman-readable description of what is being waited for.
match"any" | "all"NoWhether any or all agents must satisfy the condition. Defaults to "all".
timeoutAtstringNoOptional ISO-8601 timestamp at which the wait times out.

Condition kinds

KindWaits until...
"agent-closed"The agent is explicitly closed via close_agent.
"agent-idle"The agent completes its current task (becomes idle or is closed).

Result

ts
{
  waitId: string;
  agentId: string;
  status: string;
  kind: string;
  match: "any" | "all";
  resolution?: unknown;
}

Usage notes

  • Use wait_agent to synchronize between the orchestrator and sub-agents before proceeding with work that depends on their output.
  • Prefer "agent-idle" when you want to collect results from a sub-agent while it may continue to run later.
  • Prefer "agent-closed" when you need to know the sub-agent has fully terminated.
  • Use match: "any" when you want to proceed as soon as at least one agent in agentIds finishes.

Example

ts
// Wait for a single agent to close
{
  id: "wait-1",
  agentId: "researcher-1",
  kind: "agent-closed",
  description: "Waiting for research agent to finish and close."
}

// Wait for any one of several agents to become idle
{
  id: "wait-2",
  agentId: "writer-1",
  agentIds: ["writer-1", "writer-2", "writer-3"],
  kind: "agent-idle",
  match: "any",
  description: "Waiting for the first writer agent to complete its draft."
}

Released under the Apache 2.0 License.