8 Multi-Agent Orchestration Patterns for Agent Swarms
How you coordinate agents matters more than how many you have. The same three agents can behave like a rigid pipeline, a team with a manager, or a self-correcting swarm, depending only on the orchestration pattern.
This guide walks through the eight orchestration patterns that SwarmAI implements as process types, from the most predictable to the most autonomous. For each one you get how it works, when to use it, and the Java code to run it. If you have not built a swarm yet, start with the step-by-step tutorial.
Quick reference
| Pattern | How it works | Needs a manager | Best for |
|---|---|---|---|
| Sequential | Tasks run in dependency order | No | Pipelines: research, then analyse, then write |
| Parallel | Independent tasks run concurrently in layers | No | Fan-out work such as comparing several options |
| Hierarchical | Manager plans, workers execute, manager synthesises | Yes | Open-ended problems that need a plan |
| Iterative | Reviewer approves or returns work with feedback | Yes (reviewer) | Quality-critical output |
| Self-improving | Review loop that also creates missing skills | Yes | Tasks where the swarm lacks a capability |
| Swarm | Discover targets, run one self-improving agent per target, synthesise | Yes | Many similar sub-problems found at run time |
| Distributed | Work partitioned across nodes with RAFT consensus | Yes (coordinator) | Large workloads across machines |
| Composite | Chains several processes into stages | Per stage | Multi-phase workflows |
In code, every pattern is a value of the ProcessType enum. Your agents and tasks stay the same when you switch between them.
1. Sequential
Tasks run in dependency order, and each task receives the outputs of the tasks it depends on as context. This is the most predictable pattern and the right default.
SwarmOutput result = Swarm.builder()
.agents(List.of(researcher, writer))
.tasks(List.of(research, report))
.process(ProcessType.SEQUENTIAL)
.build()
.kickoff(Map.of("topic", "AI agents in enterprise"));
Use it when the steps are known in advance and each one needs the previous result. Avoid it when steps are independent, because you are leaving speed on the table.
2. Parallel
SwarmAI sorts tasks by their dependencies into layers and runs each layer concurrently. Tasks with no dependency between them run at the same time, and a task that depends on several others waits for all of them.
SwarmOutput output = Swarm.builder()
.agents(List.of(marketAnalyst, techAnalyst, financeAnalyst, summarizer))
.tasks(List.of(marketTask, techTask, financeTask, summaryTask))
.process(ProcessType.PARALLEL)
.build()
.kickoff(inputs);
Here the market, technical and financial analyses run concurrently, and the summary task, which depends on all three, runs last. Each task has a timeout (perTaskTimeoutSeconds, 300 by default), and maxConcurrentLlmCalls caps how many model calls run at once so you stay inside provider rate limits.
Use it when sub-tasks are independent. Watch out for rate limits and cost: parallel runs spend tokens faster.
3. Hierarchical
A manager agent first produces an execution plan. The worker agents then run their tasks in dependency order with that plan as context, and the manager synthesises their results into the final answer. This is the classic "team with a lead" pattern, taken from the competitive market analysis example:
Swarm researchSwarm = Swarm.builder()
.id("research-swarm")
.agent(marketResearcher)
.agent(dataAnalyst)
.agent(strategist)
.agent(reportWriter)
.managerAgent(projectManager)
.task(marketResearchTask)
.task(dataAnalysisTask)
.task(strategyTask)
.task(reportTask)
.process(ProcessType.HIERARCHICAL)
.verbose(true)
.maxRpm(20)
.build();
Use it when the problem is open-ended and benefits from someone thinking about the approach before the work starts. Tip: give the manager a role focused on planning and checking, not doing. A manager that tries to do the work itself produces worse plans.
4. Iterative
A reviewer agent reads the output and answers either APPROVED or NEEDS_REFINEMENT with feedback. The feedback is fed back to the worker, which revises, until the reviewer approves or the iteration limit is reached. The SwarmAI source credits AutoGen's critic agents as the inspiration for this pattern.
SwarmOutput output = Swarm.builder()
.agents(List.of(writer))
.tasks(List.of(draftTask))
.process(ProcessType.ITERATIVE)
.managerAgent(reviewer) // Acts as reviewer
.config("maxIterations", 3) // Max review cycles
.config("qualityCriteria", "Must include data-backed claims")
.build()
.kickoff(inputs);
Use it when output quality matters more than latency: reports, code, customer-facing text, investment memos. Always set maxIterations (the default is 3) and a concrete qualityCriteria. A vague criterion such as "make it good" leads to reviewers that never approve.
5. Self-improving
The self-improving process extends the iterative loop. The reviewer reports two kinds of problems: quality issues, which go back to the worker as feedback, and capability gaps, which mean the swarm lacks a skill it needs. A capability gap triggers the swarm to generate a new skill, validate it and register it, then retry with the new capability.
SwarmOutput output = Swarm.builder()
.agents(List.of(analyst))
.tasks(List.of(analysisTask))
.process(ProcessType.SELF_IMPROVING)
.managerAgent(reviewer)
.config("maxIterations", 5)
.config("qualityCriteria", "Every figure must be computed, not estimated")
.build()
.kickoff(inputs);
Generated skills run in a sandbox, and there is a hard ceiling of 20 iterations whatever you configure. Use it when the task may need capabilities you did not anticipate, such as a specific calculation or data transformation. Combine it with a budget and approval gates (see Governing Autonomous AI Agents), because this is where autonomy is highest.
6. Swarm
The SWARM process is SwarmAI's most autonomous single-node pattern. It runs in three phases:
- The first task is a discovery task. Its agent works out what the targets are and lists each one on a line that starts with a marker you choose, for example
COMPETITOR: Microsoft Azure (Ticker: MSFT). - SwarmAI parses those lines and fans out one self-improving agent per target, in parallel. All of them share one skill registry, so a skill one agent creates is available to the others.
- A final step synthesises the results.
This is the real configuration from the competitive research swarm example, which discovers competitors and then analyses each one in its own agent:
Swarm swarm = Swarm.builder()
.id("competitive-research-swarm")
.agent(researchAnalyst)
.agent(reportWriter)
.agent(estimateValidator)
.managerAgent(reviewer)
.task(discoveryTask)
.task(analysisTask)
.task(reportTask)
.task(validationTask)
.process(ProcessType.SWARM)
.config("maxIterations", 5)
.config("maxParallelAgents", 5)
.config("targetPrefix", "COMPETITOR:")
.config("qualityCriteria",
"1. Each company has real financial data (revenue, market cap) with sources cited\n" +
"2. Product comparison includes specific features and pricing tiers\n" +
"3. SWOT analysis is company-specific, not generic\n" +
"4. Recommendations are actionable and backed by the analysis\n" +
"5. All data from API calls, not LLM knowledge")
.build();
The discovery task's description tells the agent to print one COMPETITOR: line per target, and targetPrefix tells the coordinator which lines to fan out on. Without a prefix the coordinator looks for IP addresses, which suits its original use case: discovering hosts in a security scan and assessing each one in parallel.
Use it when you do not know in advance how many sub-problems there are, and each one deserves its own focused agent. maxParallelAgents (default 5) caps the fan-out.
7. Distributed
The DISTRIBUTED process spreads work across several nodes. You declare the goal, the framework partitions the work, and RAFT consensus coordinates the nodes so the run survives individual node failures. It needs the swarmai-distributed module on the classpath and a coordinator agent.
Use it when a single machine is not enough, or when you need fault tolerance for long-running swarms. For most teams this is a later step, not a starting point.
8. Composite
Real workflows often have phases that each need a different pattern: for example, parallel research, then a hierarchical analysis, then an iterative review of the final report. The composite process chains processes into stages and passes each stage's output to the next.
Composite workflows are built with CompositeProcess.of(...) in Java, or with the stages: key in the YAML DSL, rather than through Swarm.builder().
Beyond fixed patterns: graphs
When none of the eight patterns fits, SwarmAI also has a graph API, SwarmGraph, for explicit nodes, edges and conditional routing, with checkpoints and the ability to pause before a node for human review. It is the right tool for workflows with branches such as "if the score is below 80, go back to the analyst".
How to choose
Start with the least autonomy that solves the problem, and move up only when you see a concrete gap:
- Start sequential. It is easy to debug and cheap.
- If steps are independent, go parallel.
- If output quality is the problem, add a reviewer with iterative.
- If the problem needs a plan you cannot write in advance, use hierarchical.
- If the swarm keeps failing for lack of a capability, try self-improving.
- If the number of sub-problems is only known at run time, use swarm.
Because switching is a one-line change to .process(...), you can measure each step against the previous one rather than guessing. Our benchmarks and demos show how swarm output compares with a single raw LLM call.
Learn more
- What Are Agentic Swarms?: the concepts behind autonomous multi-agent systems.
- How to Build an Autonomous AI Agent Swarm in Java: the hands-on tutorial.
- Examples: complete swarms for each pattern.
- Documentation: the full reference.
SwarmAI is open source under the Apache 2.0 licence. Star SwarmAI on GitHub to follow new releases.