10 Multi-Agent Collaboration Design Patterns: From Reflection to Swarm

    This article presents ten implementation-agnostic design patterns for multi-agent systems, organized along two axes: how control is distributed and how information flows. It explains why pattern selection, state design, and termination logic matter more than tooling, then covers loop-based patterns such as reflection, debate, and consensus; parallel and aggregation patterns such as map-reduce, orchestrator-worker, and hierarchical teams; and routing and governance patterns such as routing, guardrail gates, and swarm emergence. Each pattern includes its core idea, when to use it, state design considerations, pseudocode skeletons, and common pitfalls, followed by general engineering guidelines for cost, observability, and starting simple.

    1. The Hard Part Is Architecture, Not Tooling

    Most engineering teams building multi-agent systems run into the same questions. When two agents co-write a long document, should they use a single linear pass or an iterative loop? If there is a loop, what is the maximum number of rounds, and what condition determines convergence? When five domain experts analyze the same problem, should they work sequentially, solve it independently in parallel, or aggregate their answers through voting? Once a safety review role is added, how do you define the routing conditions for the three branches: approve, block, and send back for retry?

    What these questions have in common is that none of them are about API calls. Mainstream graph-orchestration frameworks already provide strong enough primitives—nodes, edges, shared state, conditional branches, and concurrent fan-out cover most engineering needs. What actually determines whether a system succeeds is pattern selection: choosing the right collaboration topology for a given set of task constraints, and configuring the correct state structure and termination mechanism for it.

    So this article does not cover how to use any specific tool. Instead, it abstracts a set of implementation-agnostic multi-agent design patterns—ten in total—spanning the full spectrum from the lightest self-correction to decentralized swarm coordination. Each pattern includes its core idea, applicable scenarios, state design considerations, a pseudocode skeleton, and common pitfalls.

    2. The Pattern Landscape and How to Choose

    The ten patterns can be understood along two dimensions. The first is how control is distributed, from central orchestration to decentralized negotiation. The second is the shape of information flow, from a single serial chain to multiple parallel paths that are later aggregated.

    • Reflection: a single agent generates, and the same agent or a peer role reviews, with a loop back.
    • Debate: multiple roles speak in parallel, and a moderator or a vote decides.
    • MapReduce: dynamic fan-out to subtasks, then merge and synthesize.
    • Pipeline: a fixed sequence of handoffs, with no loop.
    • Routing: a dispatcher node sends requests to different branches based on a classification result.
    • Guardrail gate: a three-way route—approve, block, or send back—inserted at a critical node.
    • Orchestrator-worker: a central planner dynamically decomposes tasks and dispatches them.
    • Hierarchical: multiple layers of managers, each managing a small group of workers.
    • Consensus: multiple replicas solve independently, then converge by a consistency rule.
    • Swarm: decentralized local rules drive global behavior.

    The first selection principle is: if a simple pattern can solve the problem, do not introduce a complex one. Every additional agent and every additional loop brings a non-linear increase in token cost, latency, and debugging difficulty.

    3. Loop-Based Patterns with Termination Conditions

    3.1 Reflection

    The core chain is three stages—generate, review, revise—with a conditional edge deciding whether to re-enter generation. The key design is not in the generation node but in the output structure of the review node: the review must return a structured result containing at least three fields—whether it passed, a list of issues, and a severity level—otherwise the loop cannot be evaluated programmatically.

    1. def review(state):
    2. issues = critic(state["draft"]) # structured output
    3. passed = len([i for i in issues if i.level == "high"]) == 0
    4. return {"issues": issues, "passed": passed}
    5. def route(state):
    6. if state["passed"]:
    7. return "END"
    8. if state["round"] >= MAX_ROUNDS:
    9. return "finalize_with_warning" # fallback to avoid an infinite loop
    10. return "write"

    There are three engineering points. First, set up both a maximum round count and a budget cap as double insurance. Second, explicitly write the previous round’s issue list into the shared state at every round, so review feedback is not lost in transit. Third, provide a fallback exit when the limit is reached—for example, output the current best version with a risk warning rather than failing outright.

    3.2 Debate

    Multiple roles independently take a position on the same problem, and a moderator then summarizes and decides. It fits tasks with clear multiple perspectives, such as fact-checking, choosing between options, and anticipating risks; it does not fit deterministic tasks with a clear objective. In implementation, use concurrent calls plus structured output parsing, and give each role a different system prompt and evaluation dimension. Otherwise you get highly homogeneous opinions, and the debate degrades into repetition.

    3.3 Consensus

    The difference from debate is that consensus emphasizes multiple replicas solving independently and then converging by a rule—for example, adopt the result when the majority agrees, and add another round when they disagree. It is better suited to extraction and classification tasks with high stability requirements.

    4. Parallel and Aggregation Patterns

    4.1 MapReduce

    A dispatch node splits a large task into mutually independent subtasks, fans out dynamically to multiple worker nodes, and once all of them return, a merge node synthesizes the results. This depends on dynamic fan-out: the dispatch node decides the number of branches at runtime, rather than hard-coding it during orchestration.

    1. def dispatch(state):
    2. subs = split(state["goal"]) # decide the number of branches at runtime
    3. return [Command(goto="worker", update={"sub": s}) for s in subs]
    4. def merge(state):
    5. return {"result": synthesize(state["all_results"])}

    Watch out for three kinds of problems: overlapping subtask splits that produce conflicting conclusions; partial branch failures that leave gaps in the merged result; and excessive concurrency that triggers rate limiting. The corresponding practices are to require splits to be mutually exclusive and complete, to validate the completeness of sub-results before merging, and to cap concurrency and add backoff retries.

    4.2 Orchestrator-Worker and Hierarchical Teams

    A central planner first produces a task list, then dispatches items one by one to workers, and finally collects the results. As the task scale keeps growing, introducing intermediate managers creates a hierarchical structure in which each layer communicates only with adjacent layers, keeping complexity within a manageable range. The cost is that the more layers there are, the more obvious error accumulation and information decay become, so the depth is generally kept to no more than three layers.

    5. Routing and Governance Patterns

    5.1 Routing

    The dispatcher node first makes an intent or type judgment, then decides which branch to take next. The design point is that the classification result must fall into a finite enumerated set, and a default branch must be reserved for inputs that cannot be recognized.

    5.2 Guardrail Gate

    Insert a review node before write operations, outbound actions, or high-risk outputs, forming a three-way route: approve means continue; block means terminate with a reason; insufficient evidence or a fixable judgment means send it back upstream for retry, while writing the review comments into the state for the next round.

    1. def gate_route(state):
    2. v = state["review"]
    3. if v.decision == "approve":
    4. return "execute"
    5. if v.decision == "block":
    6. return "reject"
    7. return "revise" if state["retry"] < MAX_RETRY else "reject"

    Governance also requires supporting measures: full-chain observability that records the input summary and decision basis of every routing step; idempotency for critical actions to avoid duplicate side effects from retries; and least privilege, so worker nodes can only access the resources necessary to complete the task.

    5.3 Swarm

    A large number of simple individuals interact under local rules, and global behavior emerges bottom-up. It fits exploratory, open-ended problems and offers the weakest controllability, so in practice it must be combined with global constraints and observability.

    6. General Engineering Guidelines Across Patterns

    First, state is the contract. Every field in the shared state should have a clear producer and consumer, and no node should write to it arbitrarily.

    Second, design termination conditions first. Figure out under what conditions the system must stop before designing the loop.

    Third, structured output is the prerequisite for automation. The output of review, routing, and decision nodes must be a parseable structure, not free text.

    Fourth, cost and latency must be budgetable. Set caps on rounds, concurrency, and call counts per request, and bring them into monitoring and alerting.

    Fifth, make it observable and replayable. Only by saving the decision basis of every hop can you locate whether the problem is a splitting error, a routing error, or a generation quality issue.

    Sixth, start with a single agent. Introduce a review loop only when single-pass generation quality genuinely falls short; introduce debate or consensus only when multiple perspectives genuinely affect the conclusion.

    7. Conclusion

    The engineering maturity of a multi-agent system does not depend on how many roles are integrated, but on whether pattern selection matches the task structure, whether state and termination conditions are rigorous, and whether governance and observability are in place. Treat these ten patterns as a vocabulary: establish a baseline with the simplest pattern first, then add complexity gradually based on observable data—that is the controllable path of evolution. When deploying on the cloud, you can use a container platform to host the orchestration runtime, a message queue to decouple asynchronous branches, logging services and monitoring alerts to ensure observability, and object storage to keep intermediate artifacts for replay, turning architecture decisions into a stable, operable production system.