Orchestrate multiple agents to collaborate on complex tasks. A lead agent decomposes a task, delegates sub-tasks to peer agents, collects results, and synthesizes a final answer.
Swarm mode enables a group of agents to work together on a single complex task. Instead of one agent doing everything, the work is split across multiple agents operating in parallel.
User sends complex task
│
▼
┌──────────────────┐
│ Lead Agent │
│ │
│ Decomposes task │
│ into sub-tasks │
└──────┬───────────┘
│
┌────────┼────────┐
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐
│Worker 1│ │Worker 2│ │Worker 3│
│ │ │ │ │ │
│Sub-task│ │Sub-task│ │Sub-task│
│ A │ │ B │ │ C │
└───┬────┘ └───┬────┘ └───┬────┘
│ │ │
└──────────┼──────────┘
▼
┌──────────────────┐
│ Lead Agent │
│ │
│ Synthesizes all │
│ results into │
│ final answer │
└──────────────────┘
│
▼
Final Result
You need at least 2 agents running. The more agents, the more sub-tasks can run in parallel.
python3 main_agent_entrypoint.py \
--num-agents 3 \
--agent-names "Leader,Researcher,Analyst" \
--connector-types "none,none,none" \
--proactive-loops "no,no,no"- Go to the Swarm tab in the dashboard
- Select a Lead Agent from the dropdown (this agent will coordinate the work)
- Enter a Task (e.g., "Research the top 5 programming languages for AI and compare their strengths")
- Optionally check specific agents to include as workers (leave unchecked to use all available agents)
- Click Launch Swarm
The swarm run appears in the Active Swarm Runs section with live status updates.
Prefix your message with swarm: in any connected chat:
swarm: Research the latest trends in renewable energy and summarize findings
The agent receiving the message becomes the lead agent and automatically launches a swarm run.
- Launch: User triggers a swarm (dashboard or connector)
- Hub creates swarm run: Assigns a unique run ID, records the task and lead agent
- Lead agent receives tagged message: The hub sends the lead agent a special message:
[SWARM:<run_id>] You are the LEAD AGENT for this swarm task. Your job: decompose this task and delegate sub-tasks to peer agents. TASK: <the user's task> Available peer agents: Worker1, Worker2, Worker3 Instructions: - Break the task into specific sub-tasks - Use "send_agent_message" tool to delegate each sub-task to a peer agent - Each agent should be given a clear, specific task - After delegating, use "send_user_message" to confirm what was delegated - Lead agent plans and delegates: Using its LLM planner, the lead agent decomposes the task and uses the
send_agent_messagetool to send sub-tasks to peer agents - Peer agents work: Each peer agent processes its assigned sub-task independently
- Results collected: When peer agents complete their work and send results via
send_user_message, the hub automatically detects and collects results for the swarm run - Aggregation: Once all expected sub-results are in (or timeout), the hub sends an aggregation task to the lead agent with all collected results
- Final synthesis: The lead agent combines all results into a final answer
- Completion: The final result is displayed on the dashboard (and sent back through the connector if triggered from one)
| Status | Meaning |
|---|---|
| running | Swarm is active — agents are working |
| collecting | Sub-tasks delegated, waiting for results |
| aggregating | All results in, lead agent is synthesizing |
| completed | Final result is ready |
| cancelled | Manually cancelled by user |
| failed | An error occurred during execution |
The Swarm tab has three sections:
Form to start a new swarm run:
- Lead Agent: Dropdown of active agents
- Task: Text input for the complex task
- Select Agents: Checkboxes to pick which agents participate (optional — defaults to all)
- Launch Swarm button
Cards showing currently running swarms:
- Run ID, lead agent, status badge
- Task description
- Sub-task results as they come in (expandable)
- Cancel button to stop the swarm
Cards showing finished swarms:
- Final synthesized result (highlighted)
- All sub-task results (expandable)
- Timestamps (created, completed)
- Delete button to remove from history
Swarm mode relies on the agent-to-agent messaging system. This is also available independently.
Agents use the send_agent_message tool to send messages to each other:
Tool: send_agent_message
Arguments:
agent_name: "Researcher"
message: "Research the top 3 Python web frameworks and their performance benchmarks"
The message is relayed through the hub and delivered to the target agent's message queue.
Each agent automatically discovers its peers when planning tasks. The planner's system prompt includes a live list of active agents:
Peer agents online (use "send_agent_message" to collaborate):
Researcher, Analyst, Writer
- You can delegate sub-tasks to these agents
- Be specific about what you need each agent to do
The Messages tab on the dashboard shows all agent-to-agent message history:
- Filter by agent name
- See sender, recipient, message content, and timestamp
- Send messages between agents manually from the dashboard
Swarm works from any connected chat platform.
swarm: Compare React, Vue, and Angular for enterprise applications
The Discord bot agent becomes the lead, launches the swarm, and sends the final result back to the Discord channel.
swarm: Analyze the pros and cons of microservices vs monolith architecture
Same flow — the Telegram bot agent leads the swarm and replies in the Telegram chat.
swarm: Research the best CI/CD tools for a Python project
The Slack bot agent coordinates the swarm and posts the final result back to the Slack channel.
- User sends a message starting with
swarm:in any connected chat - The connector's agent detects the prefix in
handle_message() - Agent calls
POST /api/swarm/launchon the hub with itself as lead agent - A confirmation message is sent back to the chat: "Swarm launched! Task: ..."
- When the swarm completes, the final result is routed back through the connector to the original chat
POST /api/swarm/launch
Content-Type: application/json
{
"task": "Research AI trends and summarize",
"lead_agent": "Leader",
"agents": ["Researcher", "Analyst"] // optional, defaults to all active
}
Response:
{
"status": "success",
"run_id": "swarm_abc123",
"message": "Swarm launched"
}GET /api/swarm/runs
Response:
{
"swarm_runs": [
{
"id": "swarm_abc123",
"task": "Research AI trends",
"lead_agent": "Leader",
"status": "running",
"agents": ["Researcher", "Analyst"],
"sub_results": {},
"final_result": null,
"created_at": "2026-02-18T10:30:00",
"completed_at": null
}
]
}POST /api/swarm/runs/<run_id>/cancel
DELETE /api/swarm/runs/<run_id>
- Name agents by role: Use descriptive names like "Researcher", "Analyst", "Writer" — the LLM uses these names when deciding how to delegate
- Give clear tasks: The more specific the swarm task, the better the lead agent can decompose it
- 3-5 agents is ideal: Too few and there's nothing to parallelize; too many and coordination overhead increases
- Monitor in dashboard: Watch the Swarm tab for real-time progress on active runs
- Use with workflows: For repeatable multi-agent pipelines, consider using Workflows instead — swarm is better for ad-hoc complex tasks
| Feature | Swarm | Workflows |
|---|---|---|
| Structure | Dynamic — lead agent decides how to split work | Static — predefined step sequence |
| Best for | Ad-hoc complex tasks | Repeatable pipelines |
| Agent assignment | Lead agent delegates dynamically | Each step has a pre-assigned agent |
| Data flow | Results collected by hub, aggregated by lead | Template variables pass between steps |
| Approval gates | No | Yes |
| Failure recovery | Lead agent can re-delegate | On-failure step routing |
| Trigger | Dashboard, connectors (swarm: prefix) |
Dashboard, API |
Use swarm when you want the AI to figure out how to split the work. Use workflows when you want explicit control over the pipeline.