HeavySwarm is a multi-agent orchestration system inspired by X.AI’s Grok Heavy implementation. It decomposes a task into role-specific questions, runs those questions through specialized expert agents in parallel, and then synthesizes the outputs into a single comprehensive answer. The exact set of experts is controlled by the variant parameter.
When to Use
- Complex research tasks — in-depth investigation across multiple angles
- Financial analysis — investment decisions requiring multiple viewpoints
- Strategic planning — comprehensive evaluation of options and trade-offs
- Due diligence — thorough verification and risk assessment
- Multi-faceted problems — issues that need research, analysis, and synthesis combined
Key Features
- Intelligent question generation tailored to each agent role, with its own decomposer per variant
- Image-aware decomposition: pass
imgand the questions are written from what the image shows - Three preset variants —
default(5 agents),medium(4 Grok-style agents),heavy(16 agents) - Parallel execution on a thread pool; each worker runs the autonomous loop on its question
- Synthesis agent that integrates expert outputs into a final answer
- Token usage summed across question generation and every agent, via
usage - Optional real-time
richdashboard - Multi-loop iterative refinement (each loop builds on the previous result)
- Tool integration through
worker_tools - Inherits
SerializableMixin—to_dict()is available for telemetry / persistence
Architecture
Basic Example
With Tool Integration
Selecting a Variant
Thevariant parameter controls which agents are instantiated.
SwarmVariant is exported from swarms.agents.heavy_swarm_agents. Passing an unknown variant raises ValueError during initialization.
Specialized Agents (default variant)
Research Agent
- Comprehensive information gathering
- Data collection and validation
- Source verification
- Literature review
- Statistical data interpretation
Analysis Agent
- Pattern recognition
- Statistical analysis
- Predictive modeling
- Data interpretation
- Performance metrics
Alternatives Agent
- Strategic thinking
- Creative problem-solving
- Option generation
- Trade-off evaluation
- Scenario planning
Verification Agent
- Fact-checking
- Feasibility assessment
- Risk analysis
- Compliance verification
- Quality assurance
Synthesis Agent
- Multi-perspective integration
- Comprehensive analysis
- Executive summary creation
- Strategic alignment
- Actionable recommendations
Key Parameters
str
default:"HeavySwarm"
Identifier for the swarm instance.
str
Description of the swarm’s purpose.
int
default:"900"
Seconds passed to each worker future’s
result() call. Results are read as workers finish, so it does not interrupt a running worker.str
default:"gpt-5.4"
Model used by the question-generation agent.
str
default:"gpt-5.4"
Model used by every agent the variant builds, including the synthesis agent or captain.
bool
default:"False"
Enable detailed logging output.
bool
default:"False"
Enable the real-time
rich progress dashboard.bool
default:"False"
Print each specialist worker’s output. The synthesis agent or captain always prints.
str
default:"dict-all-except-first"
Format of the returned conversation history.
Optional[tool_type]
Tools made available to every agent the variant builds.
int
default:"1"
Number of full swarm iterations. Each loop refines the previous synthesis.
Literal["default", "medium", "heavy"]
default:"\"default\""
Which agent line-up to instantiate. See Selecting a Variant above.
Methods
run(task, img=None)
Execute the full multi-phase workflow.
usage
Provider token counts summed over question generation and every agent, including the synthesis agent or captain. The total keeps growing across loops and run() calls. See Token usage.
get_questions_only(task, img=None) and get_questions_as_list(task, img=None)
Run only the decomposer and return its questions as a dict of *_question keys or as an ordered list. Useful for previewing what each worker will be asked.
to_dict()
Inherited from SerializableMixin. Returns a JSON-friendly snapshot of the swarm’s config. The agents, conversation, dashboard, and worker_tools attributes are excluded via _to_dict_exclude to keep the snapshot lightweight.
Question Generation
The question agent emits a JSON object whose schema depends on the variant. For the default variant it looks like:"medium" and "heavy" variants return one <name>_question key per specialist instead, such as harper_question. Each variant has its own decomposer prompt and schema, and the decomposer sends no temperature or top-p, so it also runs on Anthropic models. When you pass img, the decomposer is told an image accompanies the task and reads it.
Example generated questions for “Invest in NVIDIA?”:
Multi-Loop Refinement
Withmax_loops > 1 the swarm iterates, each loop feeding the previous synthesis back as context:
- Loop 1: original task only
- Loop 2:
"Previous loop results: <output>\n\nOriginal task: <task>\n\n"followed by an instruction to refine and build on the previous loop - Loop 3: same shape — refine, fill gaps, deepen the analysis
run(), so a later synthesis also sees the earlier loops’ questions and answers.
Dashboard Features
Whenshow_dashboard=True, the HeavySwarmDashboard renders rich progress panels:
Configuration Panel:
- Swarm name and description
- Model configuration (question + worker)
- Timeout and worker counts
- Animated progress bars
- Per-component validation status
- Real-time generation progress
- Per-agent progress bars
- Status (INITIALIZING, PROCESSING QUERY, EXECUTING, GENERATING RESPONSE, COMPLETE, or ERROR / TIMEOUT)
- Variant-aware agent labels
- Integration progress
- Final report generation
- Completion confirmation
Use Cases
Investment Analysis
Market Research with Live Web Data
Strategic Planning
Heavy Variant for Deep Research
Performance Notes
Parallel Execution
All workers fan out on a thread pool that carries the tracing context into each thread.self.max_workers is set to int(os.cpu_count() * 0.9); it is not a constructor parameter.
Timeout
future.result() after as_completed() has already returned that future, so it does not cut a slow worker short.
Verbose Logging
Output Structure
The swarm returns the conversation history formatted byoutput_type. The default "dict-all-except-first" returns a list of message dicts, without the initial task message:
timestamp, message_id and category keys. Use output_type="final" to get only the synthesis.
Best Practices
Model Selection: use stronger models (Claude Sonnet, GPT-5.4) for worker agents on complex tasks.
- Question Quality — a stronger question-generation model produces tighter, less overlapping expert questions.
- Worker Models — balance cost vs quality for the worker pool; mixing providers via LiteLLM works out of the box.
- Loop Count — start at
max_loops=1. Add more only when the synthesis clearly needs refinement. - Variant Choice —
defaultcovers most tasks; reach forheavyonly when you genuinely benefit from 15+ specialist perspectives. - Dashboard — leave on for demos and debugging; off for production.
- Tools — supply
worker_toolswhen the task requires real-time data (search, web fetch, etc.).
Reliability Checks
reliability_check() runs automatically during __init__:
show_dashboard=True, the validation steps animate through the dashboard. Otherwise a single confirmation panel prints.
An unknown variant raises ValueError before this check, when __init__ builds the agents.
Conversation History
Access the full transcript through the conversation object:Error Handling
run() does not raise when a phase fails. It logs the error and returns a message string instead of the formatted conversation:
Related Architectures
- Mixture of Agents — parallel experts + aggregator (lighter weight)
- Hierarchical Swarm — director-worker delegation pattern
- Concurrent Workflow — simpler parallel execution
- Agent Rearrange — custom flow patterns
- Structures Catalog — full enumeration of every multi-agent structure