Why multiple agents
A single general-purpose agent works well for most tasks. Specialist agents are useful when:- A domain needs its own identity, memory, and tool profile (e.g., a patient-facing clinic assistant vs. a developer coding agent)
- You want separate channel routing per audience (e.g., WhatsApp for patients, Slack for the internal team)
- Security boundaries require isolation — one agent should not see another agent’s conversations
Agent-to-agent (A2A) communication
Agents communicate through an internal message bus. A2A is decoupled from visibility: two agents can exchange messages without sharing session history or being able to read each other’s memory.How it works
When agent A needs to delegate a task to agent B:- Agent A calls
sessions_sendwith the target agent’s session key. - The gateway validates that the target agent exists (agent existence guard — the call is rejected if the target is unknown).
- The message is delivered to agent B’s session with an
inter_sessionprovenance marker. - Agent B processes the request and responds.
- The response is delivered back to agent A.
Input provenance
Every message an agent receives carries a provenance field:| Provenance | Meaning |
|---|---|
external_user | The message came from a human via a channel (WhatsApp, Telegram, etc.) |
inter_session | The message came from another agent |
Ping-pong turns
A2A exchanges use a ping-pong model: by default, 2 turns per exchange (configurable up to a maximum of 5). This prevents runaway loops where agents keep routing to each other indefinitely.Control signals
Agents can send control signals to terminate an exchange early:| Signal | Effect |
|---|---|
REPLY_SKIP | The receiving agent skips generating a reply |
ANNOUNCE_SKIP | The announcing agent suppresses its outbound announcement |
Example: dental clinic delegation
A main assistant handles general requests. When a patient asks about appointments, the main assistant routes to a dedicated dental clinic agent that has calendar access, a patient CRM, and its own WhatsApp greeting.Setting up A2A
Create agents conversationally, then configure which agent delegates to which:Create your specialist agent
Tell your assistant what you need:The agent is created with an appropriate tool profile and workspace.
Configure delegation
Tell the main agent which requests to route:The main agent’s
AGENTS.md workspace file is updated with delegation rules.Sub-agent spawning
For tasks that require parallel execution or dynamic delegation, thesessions_spawn tool creates a sub-agent on demand. Spawned agents:
- Inherit the tool profile of the parent (unless overridden)
- Are depth-limited — spawned agents cannot themselves spawn further agents without limit, preventing infinite loops
- Run inside per-session Docker sandboxes when security policies require it (non-main sessions)
Security
- Non-main sessions can run inside per-session Docker sandboxes, isolating sub-agent execution from the host.
- Channel tool restrictions apply to each agent independently — a messaging-channel agent cannot run shell commands even when spawned by an agent that can.
- A2A messages are stored encrypted in each agent’s own session transcript (NYXENC1).
The agent existence guard means a misconfigured delegation target fails loudly — the routing call is rejected before any message is sent to an unknown agent.