Overview
TheHeavySwarm class is a sophisticated multi-agent orchestration system that decomposes a complex task into specialized questions, runs a team of agents on them in parallel, and synthesizes the results into a comprehensive response. The variant parameter selects the agent line-up — from a five-agent default team up to a sixteen-agent deep-research team — and max_loops enables iterative refinement.
The specialist workers run with max_loops="auto", so each one works through the autonomous loop on its question. The synthesis agent (or captain) runs a single loop.
Class Definition
Parameters
str
default:"HeavySwarm"
Name identifier for the swarm instance
str
Description of the swarm’s purpose and capabilities
int
default:"900"
Seconds passed to each worker future’s
result() call. Results are read as each worker finishes, so this does not interrupt a worker that is still runningstr
default:"gpt-5.4"
Language model for question generation. The decomposer sends no temperature or top-p, so it runs on providers that reject the two together, such as Anthropic
str
default:"gpt-5.4"
Language model for every agent the variant builds: the specialist workers and the synthesis agent or captain
bool
default:"False"
Enable detailed logging and debug output
bool
default:"False"
Enable rich dashboard with progress visualization
bool
default:"False"
Print each specialist worker’s output. The synthesis agent or captain always prints
str
default:"dict-all-except-first"
Output format type for conversation history
Optional[tool_type]
Tools given to every agent the variant builds, including the synthesis agent or captain
Optional[int]
default:"1"
Maximum number of execution loops for the entire swarm. Each loop builds upon previous results for iterative refinement
Literal["default", "medium", "heavy"]
default:"\"default\""
Which agent line-up to instantiate. See Selecting a Variant below. Passing an unknown variant raises
ValueError during initialization, when the agents are builtSelecting a Variant
Thevariant parameter controls which agents are created and how many specialized questions the task is decomposed into.
SwarmVariant is exported from swarms.agents.heavy_swarm_agents.
"medium" roster
"heavy" roster
A Grok captain decomposes the task into 15 domain-specific questions; the 15 specialists answer them in parallel, then the captain synthesizes a single response.
Specialized Agents (default variant)
With the default variant, the HeavySwarm creates and manages 5 specialized agents:Research Agent
Expert in comprehensive information gathering, data collection, market research, and source verification. Specializes in systematic literature reviews, competitive intelligence, and statistical data interpretation. System Prompt Focus:- Comprehensive task analysis
- Evidence-based research
- Source credibility assessment
- Reproducible methodologies
Analysis Agent
Expert in advanced statistical analysis, pattern recognition, predictive modeling, and causal relationship identification. Specializes in regression analysis, forecasting, and performance metrics development. System Prompt Focus:- Data quality assessment
- Statistical rigor
- Quantified uncertainty
- Practical interpretation
Alternatives Agent
Expert in strategic thinking, creative problem-solving, innovation ideation, and strategic option evaluation. Specializes in design thinking, scenario planning, and exploring diverse solutions. System Prompt Focus:- Diverse option generation
- Trade-off analysis
- Risk assessment
- Implementation planning
Verification Agent
Expert in validation, feasibility assessment, fact-checking, and quality assurance. Specializes in risk assessment, compliance verification, and implementation barrier analysis. System Prompt Focus:- Fact-checking protocols
- Feasibility validation
- Risk identification
- Evidence triangulation
Synthesis Agent
Expert in multi-perspective integration, comprehensive analysis, and executive summary creation. Specializes in strategic alignment, conflict resolution, and holistic solution development. System Prompt Focus:- Multi-input integration
- Consensus building
- Prioritized recommendations
- Stakeholder communication
Methods
run()
str
required
The main task to analyze and iterate upon
str
Image input if needed for visual analysis tasks
Any
The conversation history formatted according to
output_type (default "dict-all-except-first", which returns a list of message dicts covering the question-generation, agent, and synthesis output — excluding the initial task message — not just the synthesis agent’s final string). Pass output_type="str-all-except-first" for a plain string, or output_type="final" / "last" to get only the last message’s content.run() does not raise when a phase fails. It returns an error string instead, such as "Error in question generation: ..." or "Failed to execute agents in loop 1: ...". If one worker raises, the error is logged, that worker’s answer is missing from the conversation, and the other workers continue.- Clears the conversation, so each call starts from an empty history, and adds the task
- For first loop: Execute original task with full orchestration
- For subsequent loops: Combine previous results with original task as context
- Question generation: Generate specialized questions for the active variant’s agents. When
imgis given, the decomposer sees the image too, so the questions refer to what it shows - Parallel execution: Run the variant’s specialized agents concurrently, each on its own question and the image
- Synthesis: The synthesis agent or captain receives the conversation as chat turns (the task, the generated questions and every worker’s answer) and writes the final response
- Iteration: Repeat for max_loops, building upon previous results
usage
usage of each agent the variant built, including the synthesis agent or captain. Keys are input_tokens, output_tokens, cached_tokens, reasoning_tokens and total_tokens. The total grows across loops and across run() calls, and each read returns a new dict. See Token usage.
reliability_check()
- worker_model_name is set
- question_agent_model_name is set
ValueError: If a required model name is missing
variant raises ValueError earlier in __init__, when the agents are built.
show_swarm_info()
show_dashboard=True. Shows:
- Swarm identification (name, description)
- Execution parameters (timeout, max workers)
- Model configurations (question and worker models)
execute_question_generation()
question_agent_model_name, without running the worker agents or synthesis. Each variant has its own decomposer prompt and function schema. Returns the raw parsed tool-call output, including thinking, the per-agent *_question keys, tool_call_id, and function_name (or an error key if the arguments could not be parsed). Returns an empty dict when the model makes no tool call.
str
required
The main task to analyze and decompose into specialized questions
str
Image that accompanies the task. The decomposer reads it, so a visual task is not decomposed from the sentence alone
get_questions_only()
*_question keys (filters out thinking, tool_call_id, and function_name). Useful for previewing or debugging question generation without running the full swarm.
str
required
The main task or query to decompose into specialized questions
str
Image passed to the decomposer with the task
Dict[str, str]
Clean dictionary of
*_question keys for the active variant (research_question, analysis_question, alternatives_question, verification_question for the default variant; harper_question, benjamin_question, lucas_question for "medium"; one key per specialist for "heavy"), or {"error": ...} on failureget_questions_as_list()
get_questions_only().
str
required
The main task or query to decompose into specialized questions
str
Image passed to the decomposer with the task
List[str]
Ordered list of the active variant’s questions (for the default variant: research, analysis, alternatives, verification, in that order), or a single-item list containing an error message on failure
Question Generation Schema
The default variant decomposes the task into four specialized questions:"medium" and "heavy" variants use their own schemas (3 and 15 questions respectively), with one <name>_question key per specialist, for example harper_question.
Usage Example
With an image
Multi-Loop Execution
Themax_loops parameter enables iterative refinement:
- Loop 1: Initial analysis of the task
- Loop 2+: Refinement based on previous results
- Each loop builds upon context from previous iterations
- Enables deeper analysis and progressive refinement
Dashboard Features
Whenshow_dashboard=True, the HeavySwarm displays:
- Configuration Panel: Swarm parameters and settings
- Reliability Checks: Animated validation with progress tracking
- Question Generation: Real-time progress for specialized questions
- Agent Execution: Individual progress bars for each agent
- Synthesis Phase: Integration and final report generation
- Completion Summary: An “analysis complete” panel
Performance Optimization
- Parallel Execution: The active variant’s specialized agents run concurrently
- Thread Pool: Workers run across a pool sized to roughly 90% of the host’s CPU cores
- Timeout:
timeoutis applied when each finished worker’s result is read; it does not stop a running worker