Overview
The swarm workflow is triggered by settingforce_swarm: true in the task context. It uses the same POST /api/v1/tasks endpoint as all other workflows — no separate endpoint is needed.
Swarm mode decomposes your query into subtasks, spawns persistent agents that work in parallel with inter-agent messaging, and synthesizes results into a unified response.
Submitting a Swarm Task
Endpoint
Request Body
Swarm-Specific Context Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
force_swarm | boolean | false | Required to trigger swarm workflow |
model_tier | string | (auto) | Model tier for agent execution: small, medium, large |
session_id, mode, model_tier, model_override, provider_override) work with swarm tasks.
The
force_swarm flag must be set inside the context object, not as a top-level parameter. The swarm must also be enabled in the server configuration (workflows.swarm.enabled: true in features.yaml).Example: Basic Swarm Task
Response
X-Workflow-ID: Temporal workflow identifier (same astask_id)X-Session-ID: Session identifier
Submit + Stream
Use the combined endpoint to submit and get a stream URL in one call:Monitoring Swarm Progress
SSE Event Stream
Swarm-Specific Events
| Event Type | agent_id | Description |
|---|---|---|
WORKFLOW_STARTED | swarm-supervisor | Swarm workflow initialized |
PROGRESS (planning) | swarm-supervisor | Task decomposition in progress |
LEAD_DECISION | swarm-lead | Lead made a coordination decision (spawn, assign, revise, etc.) |
TASKLIST_UPDATED | swarm-lead | Task dependency graph changed |
TEAM_STATUS | swarm-lead | Team composition changed (agent spawned or shut down) |
AGENT_STARTED | Agent name (e.g., takao) | Individual agent began execution |
PROGRESS (iteration) | Agent name | Agent iteration progress |
AGENT_COMPLETED | Agent name | Individual agent finished |
PROGRESS (synthesizing) | swarm-supervisor | Combining results from all agents |
WORKFLOW_COMPLETED | swarm-supervisor | Final synthesis complete |
Example SSE Output
Task Status Response
Swarm Metadata
When a swarm workflow completes, the status response includes swarm-specific metadata:Metadata Fields
| Field | Type | Description |
|---|---|---|
metadata.workflow_type | string | Always "swarm" for swarm workflows |
metadata.total_agents | integer | Total agents that participated (initial + dynamic) |
metadata.total_tokens | integer | Total tokens consumed across all agents |
metadata.model_breakdown | array | Per-model execution summary |
metadata.model_breakdown[].model | string | Model identifier |
metadata.model_breakdown[].provider | string | Provider name |
metadata.model_breakdown[].executions | integer | Number of LLM calls with this model |
metadata.model_breakdown[].tokens | integer | Tokens consumed by this model |
metadata.model_breakdown[].cost_usd | number | Estimated cost in USD |
Server Configuration
Swarm parameters are configured inconfig/features.yaml under workflows.swarm:
| Parameter | Default | Description |
|---|---|---|
enabled | true | Must be true for force_swarm to work |
max_agents | 10 | Total cap including dynamically spawned helpers |
max_iterations_per_agent | 25 | Per-agent iteration limit |
agent_timeout_seconds | 1800 | 30-minute per-agent timeout |
max_messages_per_agent | 20 | Prevents P2P message flooding |
workspace_snippet_chars | 800 | Controls token usage from workspace context |
workspace_max_entries | 5 | Limits workspace entries per topic in agent prompt |
max_total_llm_calls | 200 | Maximum LLM calls across all agents |
max_total_tokens | 1000000 | Maximum tokens consumed across all agents |
max_wall_clock_minutes | 30 | Maximum wall-clock time for the entire swarm |
Error Handling and Fallback
Partial Failure
If some agents fail but at least one succeeds, the swarm workflow still produces a result using the successful agents’ outputs. If all agents fail, the response includes an error:Automatic Fallback
If the entire swarm workflow fails (decomposition error, all agents fail, etc.), Shannon automatically falls back to standard workflow routing (DAG or Supervisor). Theforce_swarm flag is removed from context to prevent recursive failures.
Related Endpoints
Submit Task
POST /api/v1/tasks (full reference)
Get Status
GET /api/v1/tasks/
Stream Events
SSE event streaming
Cancel Task
POST /api/v1/tasks//cancel