Skip to main content
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.

Variants

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.
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

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: 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.
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.
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.
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

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