Skip to main content
The 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
  • Three preset variants — default (5 agents), medium (4 Grok-style agents), heavy (16 agents)
  • True parallel execution via a ThreadPoolExecutor
  • Synthesis agent that integrates expert outputs into a final answer
  • Optional real-time rich dashboard
  • Multi-loop iterative refinement (each loop builds on the previous result)
  • Tool integration through worker_tools
  • Inherits SerializableMixinto_dict() is available for telemetry / persistence

Architecture

Basic Example

With Tool Integration

Selecting a Variant

The variant 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"
Maximum execution time per agent in seconds.
str
default:"gpt-5.4"
Model used by the question-generation agent.
str
default:"gpt-5.4"
Model used by every specialized worker agent.
bool
default:"False"
Enable detailed logging output.
bool
default:"False"
Enable the real-time rich progress dashboard.
bool
default:"False"
Print each agent’s individual output.
str
default:"dict-all-except-first"
Format of the returned conversation history.
Optional[tool_type]
Tools made available to all worker agents.
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.

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:
Example generated questions for “Invest in NVIDIA?”:

Multi-Loop Refinement

With max_loops > 1 the swarm iterates, each loop feeding the previous synthesis back as context:
Per-loop semantics:
  1. Loop 1: original task only
  2. Loop 2: "Previous loop results: <output> | Original task: <task>"
  3. Loop 3: same shape — refine, fill gaps, deepen the analysis

Dashboard Features

When show_dashboard=True, the HeavySwarmDashboard renders rich progress panels: Configuration Panel:
  • Swarm name and description
  • Model configuration (question + worker)
  • Timeout and worker counts
Reliability Check Phase:
  • Animated progress bars
  • Per-component validation status
Question Generation Phase:
  • Real-time generation progress
Agent Execution Phase:
  • Per-agent progress bars
  • Status (INITIALIZING, PROCESSING, GENERATING, COMPLETE)
  • Variant-aware agent labels
Synthesis Phase:
  • 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 via concurrent.futures.ThreadPoolExecutor. max_workers defaults to roughly 0.9 * os.cpu_count().

Timeout Management

Verbose Logging

Output Structure

The swarm returns the conversation history formatted by output_type. With the default "dict-all-except-first":

Best Practices

Model Selection: use stronger models (Claude Sonnet, GPT-5.4) for worker agents on complex tasks.
  1. Question Quality — a stronger question-generation model produces tighter, less overlapping expert questions.
  2. Worker Models — balance cost vs quality for the worker pool; mixing providers via LiteLLM works out of the box.
  3. Loop Count — start at max_loops=1. Add more only when the synthesis clearly needs refinement.
  4. Variant Choicedefault covers most tasks; reach for heavy only when you genuinely benefit from 15+ specialist perspectives.
  5. Dashboard — leave on for demos and debugging; off for production.
  6. Tools — supply worker_tools when the task requires real-time data (search, web fetch, etc.).
HeavySwarm is resource-intensive. Each loop runs N expert agents + a question generator + a synthesizer. Token costs scale roughly linearly with both variant and max_loops.

Reliability Checks

reliability_check() runs automatically during __init__:
When show_dashboard=True, the validation steps animate through the dashboard. Otherwise a single confirmation panel prints.

Conversation History

Access the full transcript through the conversation object:

Error Handling