Skip to content

Swarm Definitions

Swarms are defined in YAML. A swarm definition specifies the topology, agents, and budget for a swarm that can be instantiated via the CLI or API.


# A research swarm that investigates a topic and writes a report
swarm_id: research-swarm-v1
name: Research Swarm
description: >
Investigates a topic thoroughly and produces a fact-based report.
Uses parallel research + fact-checking + Norwegian report writing.
topology: hierarchical
agents:
- id: manager
role: Research Manager
model:
primary: deepseek-v3
fallback: gpt-4o-mini
temperature: 0.3
system_prompt: |
You are a research manager. Your job:
1. Analyze the research question
2. Break it into 2-4 subtopics
3. Send each to a researcher
4. Collect results and send to fact-checker
5. Send verified findings to writer
6. Return the finished report
tools: [delegate]
- id: researcher
role: Researcher
instances: 3
model: deepseek-v3
temperature: 0.7
system_prompt: |
You are a thorough researcher. When you receive a subtopic:
1. Search with web_search
2. Be source-critical
3. Structure findings: main points, sources, uncertainties
Write in the target language. Be precise.
tools: [web_search]
max_tokens: 8192
- id: fact_checker
role: Fact Checker
model: gpt-4o-mini
temperature: 0.1
system_prompt: |
Verify every claim. Mark as {CONFIRMED}, {LIKELY}, or {UNCERTAIN}.
tools: [web_search]
- id: writer
role: Report Writer
model: deepseek-v3
temperature: 0.7
system_prompt: |
Write a well-structured report in the target language.
tools: []
cost_budget:
max_total_usd: 2.50
max_per_agent_usd: 0.80

FieldRequiredDescription
swarm_idYesUnique identifier, used in API calls
nameNoHuman-readable name
descriptionNoWhat this swarm does and when to use it
topologyYessequential, parallel, debate, or hierarchical
agentsYesList of agent definitions (see below)
cost_budgetNoSpending limits for this swarm

FieldRequiredDefaultDescription
idYesUnique within this swarm
roleYesWhat the agent does (shown in logs)
modelYesString ("deepseek-v3") or object with primary/fallback
instancesNo1How many copies of this agent to spawn (for parallel work)
temperatureNo0.7LLM creativity (0.0 = deterministic, 1.0 = creative)
max_tokensNo4096Maximum tokens per LLM response
system_promptNo""Core instructions for the agent
toolsNo[]List of tool names available to this agent

model: deepseek-v3
model:
primary: deepseek-v3
fallback: gpt-4o-mini # Used if primary fails or is overloaded

The fallback is used automatically when the primary model returns an error (rate limit, overload, timeout). The cost router also considers the fallback when choosing a model to fit within budget.


ToolDescription
web_searchSearch the web via Exa, Tavily, or SerpAPI
run_pythonExecute Python in an isolated sandbox
read_fileRead a file from the workspace
write_fileWrite a file to the workspace
api_callMake HTTP requests to external APIs
delegateSend a subtask to another agent

Terminal window
sverm run --definition research-swarm.yaml "Investigate X"
POST /api/v1/swarms
Content-Type: application/json
{
"template": "research-swarm-v1",
"task": "Investigate Norwegian hydrogen economy",
"max_budget_usd": 2.50
}

Sverm ships with these templates:

TemplateTopologyDescription
research-swarm-v1HierarchicalResearch any topic and produce a report
code-review-swarm-v1ParallelReview code from multiple angles (security, perf, style)
writing-swarm-v1SequentialWrite → critique → polish creative text
debate-swarm-v1DebateTwo sides argue, a judge evaluates