> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
> Use this file to discover all available pages before exploring further.

# HeavySwarm Guide

> Break a hard question into one question per specialist, answer them in parallel, and synthesize one report

`HeavySwarm` takes one hard question and attacks it from several angles at once. A question generator splits your task into one focused question per specialist. The specialists answer in parallel, each in its own autonomous loop. A synthesis agent then reads every answer and writes one report. You pick the size of the team with `variant`, and with `max_loops` the swarm can refine its own report.

The swarm builds all of its agents for you. You choose the models, not the agents.

Reference: [HeavySwarm](https://docs.swarms.world/api/heavy-swarm.md).

## Variants

| `variant` | Specialists | Synthesized by |
| - | - | - |
| `"medium"` | Harper (research and facts), Benjamin (logic, math and code), Lucas (creative and contrarian) | Captain-Swarm |
| `"default"` | Research, Analysis, Alternatives and Verification agents | Synthesis-Agent |
| `"heavy"` | 15 domain specialists, from Harper (creative writing) to Noah (systems thinking) | Grok |

`question_agent_model_name` sets the model that writes the questions. `worker_model_name` sets the model for every specialist and for the synthesizer. Both default to `gpt-5.4`.

## 1. Preview the questions

`get_questions_only()` runs only the question generator, which is one model call. Use it to see how the swarm will split a task before you pay for a full run.

```python theme={null}
from swarms import HeavySwarm

swarm = HeavySwarm(
    name="Pricing-Review",
    variant="medium",
    question_agent_model_name="gpt-5.4-mini",
    worker_model_name="gpt-5.4-mini",
)

task = (
    "Should a two-person SaaS startup switch from per-seat pricing to "
    "usage-based pricing?"
)

questions = swarm.get_questions_only(task)
for key, question in questions.items():
    print(f"{key}: {question}")
```

The medium variant returns `harper_question`, `benjamin_question` and `lucas_question`. In our run, Harper was asked for evidence from comparable companies, Benjamin for a revenue and churn model under three scenarios, and Lucas for hidden failure modes and hybrid pricing ideas. If the generator returns no questions, you get `{"error": "..."}` instead.

## 2. Run the swarm

```python theme={null}
result = swarm.run(task)

for message in result:
    print(f"--- {message['role']}")
    print(str(message["content"])[:300])

print(swarm.usage)
```

Every run makes fresh questions, so they differ from the preview. With the default `output_type="dict-all-except-first"`, `run()` returns every message after your task:

| Role | Content |
| - | - |
| `Question Generator Agent` | A dict with the generator's `thinking` and one `*_question` key per specialist |
| `Harper`, `Benjamin`, `Lucas` | Each specialist's answer, in the order they finished. Specialists run an autonomous loop, and in our run each answer began with that loop's `complete_task` summary |
| `Synthesis Agent` | The final report. This role name is used for every variant, including the captain's report |

The synthesizer receives your task and every message above as chat turns, and its prompt asks for a structured report: for the medium variant, an executive summary, each specialist's findings, conflict resolution, recommendations, risks and next steps.

> [!WARNING]
>
> A heavy swarm is expensive. Each specialist plans, thinks and works through several model calls. This run, with `gpt-5.4-mini` and three specialists, used about 590,000 input tokens, most of them cached. Check `swarm.usage` after a first run before you scale up the variant or the loop count.

## 3. Compare variants

The default variant splits the task into four questions. `get_questions_as_list()` returns them in a fixed order: research, analysis, alternatives, verification.

```python theme={null}
default_swarm = HeavySwarm(
    question_agent_model_name="gpt-5.4-mini",
    worker_model_name="gpt-5.4-mini",
)

print(list(default_swarm.agents))

for number, question in enumerate(default_swarm.get_questions_as_list(task), 1):
    print(f"{number}. {question}")
```

`agents` prints `['research', 'analysis', 'alternatives', 'verification', 'synthesis']`. The heavy variant builds 16 agents and asks 15 questions, so it costs several times as much as the medium one.

## 4. Refine over several loops

With `max_loops=2`, the swarm runs twice. The second time, the question generator gets the first report and your task, and writes questions that dig into what is still missing. The synthesizer always works from your original task. `output_type="final"` returns only the last report.

```python theme={null}
swarm = HeavySwarm(
    name="Pricing-Review",
    variant="medium",
    question_agent_model_name="gpt-5.4-mini",
    worker_model_name="gpt-5.4-mini",
    max_loops=2,
    output_type="final",
)

final_report = swarm.run(task)
print(final_report[:1500])
```

In our run, the second report opened with an executive summary and a section for each specialist. It also said that Harper could not check primary sources, because the specialists had no search tool. Pass tools such as a web search with `worker_tools`. Every agent in the swarm gets them, the synthesizer too.

## Reading the output

| You want | Use |
| - | - |
| Only the final report | `output_type="final"` |
| Every question, answer and report | The default `output_type="dict-all-except-first"` |
| Everything as one string | `output_type="str-all-except-first"` |
| The questions, without running the workers | `get_questions_only()` or `get_questions_as_list()` |
| Tokens spent across every run | `swarm.usage` |

Each `run()` clears the conversation and resets every agent, so a reused swarm starts fresh.

## When something fails

* **No questions.** If the question generator returns no questions or unreadable ones, `run()` raises `RuntimeError("Error in question generation: ...")`. `get_questions_only()` returns `{"error": ...}`, and `get_questions_as_list()` returns a one-item list starting with `Error:`.
* **A specialist fails.** The error is logged and that specialist's answer is left out of the conversation. The other specialists continue, and the synthesizer writes its report from the answers it has.
* **The synthesizer fails.** `run()` raises its error.

## Tips

* **Start with `variant="medium"`.** It has the fewest agents and shows the whole flow.
* **Watch it live.** `show_dashboard=True` shows progress for each phase, and `agent_prints_on=True` prints each specialist's output. The synthesizer always prints its report.
* **Specialists work in threads.** The pool is sized to 95% of the machine's CPU cores, with at least one thread.

## Next steps

* [HeavySwarm reference](https://docs.swarms.world/api/heavy-swarm.md)
* [Autonomous mode](https://docs.swarms.world/agents/autonomous-mode.md), the loop each specialist runs
* [Token usage](https://docs.swarms.world/agents/token-usage.md)
* [Runnable scripts](https://github.com/kyegomez/swarms/tree/master/examples/multi_agent/heavy_swarm_examples)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.