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.
Overview
TheAdvisorSwarm implements the advisor strategy described in Anthropic’s research (April 2026). It pairs a cheaper executor model that drives the task end-to-end with a powerful advisor model consulted on-demand between executor turns.
The executor runs every turn. The advisor is on-demand — consulted between executor turns when budget allows. Both agents read from and write to the same shared conversation context. The advisor never calls tools or produces user-facing output.
This is provider-agnostic: any model supported by LiteLLM works for either role.
The swarm follows this workflow:
- User task goes into the shared conversation
- Before each executor turn, the advisor reads the full shared context and provides guidance (if budget allows)
- The executor reads the full shared context (including any advisor guidance) and produces output
- Both advisor guidance and executor output are added to the shared conversation
- Repeat for
max_loopsexecutor turns
Installation
Key Features
| Feature | Description |
|---|---|
| Executor-Driven Loop | The executor runs every turn — it’s the main driver |
| On-Demand Advisor | Advisor is consulted between turns, not in a fixed sequence |
| Shared Context | Both agents read from and write to the same conversation |
| Budget Control | max_advisor_uses caps advisor consultations per run |
| Provider-Agnostic | Any LiteLLM-supported model works for either role |
| Custom Agents | Pass pre-configured agents with tools, MCP, or any Agent settings |
Attributes
Human-readable name
Description of the swarm’s purpose
Model for the executor agent
Model for the advisor agent
System prompt for the executor
System prompt for the advisor
Max advisor consultations per
run(). 0 = executor runs alone.Number of executor turns
Format for output (dict, str, list, final, json, yaml)
Enable detailed logging
Pre-configured Agent for execution (e.g., with tools or MCP)
Pre-configured Agent for advising
Tools available to the executor agent only
| Exception | Condition |
|---|---|
ValueError | If max_advisor_uses < 0, max_loops < 1, or model names are empty |
Methods
run()
Execute the advisor-executor orchestration flow.task(str): The task to accomplishimg(str, optional): Optional single image inputimgs(List[str], optional): Optional list of image inputs
output_type
batched_run()
Run the swarm on multiple tasks sequentially.tasks(List[str]): List of task strings
Usage Examples
Basic Usage
Multi-Turn with Advisor Guidance
Run the executor for multiple turns, with the advisor providing guidance before each:Custom Executor with Tools
Pass a pre-configured executor agent with tools while keeping the advisor tool-free:Executor Only (No Advisor)
Setmax_advisor_uses=0 to run the executor alone:
Different Providers
The swarm is provider-agnostic. Use any models LiteLLM supports:Architecture Details
Shared Context
Both agents read from and write to the sameConversation object. This mirrors the Anthropic diagram where the advisor reads the same context as the executor. On each turn:
- The advisor reads
conversation.get_str()— sees everything so far - The advisor’s guidance is added to the conversation
- The executor reads
conversation.get_str()— sees the task, any prior output, and the advisor’s guidance - The executor’s output is added to the conversation
Advisor Budget
Themax_advisor_uses parameter controls how many times the advisor is consulted:
max_advisor_uses | max_loops | Behavior |
|---|---|---|
0 | 1 | Executor runs alone — no advisor |
1 | 1 | Advisor guides once, executor runs once |
3 | 3 | Advisor guides before each of 3 executor turns |
1 | 3 | Advisor guides first turn only, executor runs 3 turns |
Multi-Turn Execution
Whenmax_loops > 1, the executor runs multiple turns. Each turn, it reads the full conversation — including its own previous output and any advisor guidance — so it can build on prior work. The advisor’s budget is distributed across turns: it is consulted before each executor turn until the budget is exhausted.