Multi-Agent Cooperation PatternsOpen in Colab
Agentic project loop
Task definition·Context & tools·Orchestration loop·Evaluation·Guardrails·Operations feedback

Multi-Agent Cooperation Patterns

A single agent (no matter how capable) is still a single point of failure. Its reasoning can go off-track, its training may have blind spots, and its confidence calibration is imperfect. The solution is the same one humans discovered for high-stakes decisions: involve more minds.

Multi-agent cooperation is the umbrella term for architectures in which two or more agents work together on the same problem. The three patterns below (voting, role-based, and debate) span a spectrum from breadth (many independent views) to depth (iterative argumentation). Choosing the right pattern is an engineering trade-off, not a universally correct answer.

This lesson builds on Reflection Patterns, where a single agent critiques its own output. Cooperation extends that idea to external critique and distributed generation. We look ahead to Safety, Registries & Adaptation in the next lesson.

Why multiple agents?

Three forces push us toward multi-agent designs:

  1. Divide and conquer. Long or complex tasks exceed a single context window or require domain expertise that no one system prompt can cover. Splitting work across specialists keeps each sub-task tractable.
  2. Diverse perspectives. Different sampling temperatures, system prompts, or model versions produce meaningfully different outputs for the same input. Aggregating those outputs smooths out idiosyncratic errors.
  3. Specialisation. Roles like planner, executor, and critic require genuinely different behaviours. Encoding them in separate agents (each with a tight system prompt) is cleaner than asking one agent to context-switch mid-conversation.

Coordination overhead is real

Adding agents multiplies API calls, latency, and cost. Each pattern below has a different overhead profile. Always benchmark against the simpler single-agent baseline before committing to a multi-agent design.

Voting-based cooperation

Structure. NN independent agents each produce an answer to the same question. A coordinator aggregates the answers using a voting rule and returns the winner.

Aggregation rules

RuleDescriptionBest when
Majority voteAnswer with the most votes winsBinary or small label set
Weighted voteEach agent's vote is scaled by a confidence scoreAgents have different track records
Borda countAgents rank all options; ranks are summed; lowest total winsMultiple options, no clear majority

Majority vote is the default because it requires no calibration. Weighted voting improves accuracy when you can estimate per-agent reliability from historical data. Borda count is useful when the task is inherently comparative (e.g. ranking search results) — with three options and three agents ranking ABCABC, ACBACB, BACBAC, the rank-sums are A=4A{=}4, B=6B{=}6, C=8C{=}8, so AA wins even though it wasn't unanimous.

Condorcet's jury theorem

The mathematical backbone of majority voting comes from political philosophy. Condorcet's Jury Theorem (1785) states:

If each voter independently has probability p>0.5p > 0.5 of choosing the correct option, then the probability of the majority being correct is:

P(majority correct)=∑k=⌈N/2⌉N(Nk)pk(1−p)N−kP(\text{majority correct}) = \sum_{k=\lceil N/2 \rceil}^{N} \binom{N}{k} p^k (1-p)^{N-k}

and this probability approaches 1 as N→∞N \to \infty.

Watch how fast the guarantee compounds for p=0.7p = 0.7:

Agents NN151125
P(majority correct)P(\text{majority correct})0.700.840.920.98

Drag pp below and watch both the theorem and its fine print — for p>0.5p > 0.5 the curve climbs toward 1, and for p<0.5p < 0.5 adding voters actively hurts:

Condorcet's jury theorem — majority accuracy vs. jury size

single agent0.70
majority of 110.922
00.250.50.75115913172125number of agents N (odd)single agent (p)

Each point is the probability that a majority of N independent agents is correct when each is right with probability p. Above p = 0.5 the curve climbs toward 1 as N grows; drag p below 0.5 and adding agents makes the majority worse — and with correlated errors (shared base model), real systems sit closer to the single-agent line than this ideal curve.

The independence assumption

The theorem requires that agent errors are independent. If all agents share the same base model, they will make correlated errors on the same inputs. Independence is best approximated by varying temperature, system prompts, or model family. Correlated errors mean the law of large numbers doesn't help you — a majority can still be confidently wrong.

The key implication for practice: majority voting pays off most for factual QA and classification tasks where there is a ground-truth answer and agent errors are uncorrelated. It helps less for open-ended generation, where "correctness" is subjective.

Forces

  • Robustness. One agent failing (or hallucinating) does not determine the output; the majority overrides it.
  • Cost. Cost scales linearly with NN. At N=5N = 5 you pay five times the per-query cost.
  • Latency. If agents run in parallel, wall-clock latency equals a single agent; if sequential, it multiplies.
  • Failure mode. Correlated errors. If the question has a common misconception, the majority may be confidently wrong.

Role-based cooperation

Structure. Agents are assigned specialised roles with distinct responsibilities. An orchestrator agent routes tasks to the right specialist and assembles the final output.

A canonical four-role setup:

RoleResponsibility
PlannerDecomposes the goal into a task list; produces a structured plan
ExecutorCarries out one task at a time; calls tools, writes code, retrieves documents
CriticEvaluates executor output against requirements; emits structured feedback
SummariserCompresses intermediate results into a compact context for the next step

The orchestrator acts as a router: it dispatches work, receives structured outputs, and decides what to do next.

Why separation of concerns matters

Each role benefits from a different system prompt and, potentially, a different model. A Planner benefits from high-level reasoning and creativity; an Executor benefits from tool-calling accuracy and format compliance; a Critic benefits from being adversarially prompted to find flaws. Mixing all four instructions into one prompt creates conflicting objectives and muddles the output.

This is the same principle behind AutoGen and CrewAI: both frameworks formalise role definitions as first-class objects, wiring agents together through structured message-passing protocols rather than ad-hoc string concatenation.

Text
User goal: "Write a Python function to merge two sorted lists"

Planner → { tasks: ["implement merge", "write tests", "review"] }
              ↓
Executor → def merge_sorted(a, b): ...  (+ test file)
              ↓
Critic  → "merge_sorted fails on empty input; add edge case"
              ↓
Executor → (revised implementation)
              ↓
Summariser → "merge_sorted(a, b) — O(n+m), handles empty lists. Tests pass."

Message schemas prevent confusion

In practice, agents communicate through structured schemas (JSON objects with typed fields), not free-form text. A Critic should emit { issues: [...], severity: "minor|major", approved: bool }, not a paragraph. Strict schemas reduce the chance that a downstream agent misinterprets the feedback as an instruction.

Forces

  • Efficiency. Each agent does one thing and does it well; no context is wasted on irrelevant instructions.
  • Debuggability. Role boundaries make it easy to pinpoint which agent introduced an error.
  • Cost. Lower than voting for the same quality level — you pay for KK sequential steps, not NN parallel duplicates.
  • Failure mode. Cascading failures. An error in the Planner propagates to every downstream role. The Critic must be adversarially tuned or it will rubber-stamp bad executor output.

Debate-based cooperation

Structure. Two (or more) agents are assigned opposing positions on a question. They argue for multiple rounds. A mediator agent synthesises the strongest points from each side and produces a final answer.

The protocol:

  1. Initialisation. The mediator presents the question. Agent A argues for position X; Agent B argues against (or for position Y).
  2. Debate rounds. Each agent reads the other's last argument and responds, attempting to rebut weak points and reinforce strong ones.
  3. Synthesis. After KK rounds, the mediator grades each side's arguments against a rubric (logical validity, evidence cited, responsiveness to the opponent's rebuttals), picks each side's strongest round, and produces a final answer that incorporates the most defensible claims from both.

Why debate produces higher quality

Debate forces red-teaming by design. Agent B's entire job is to find holes in Agent A's reasoning. This exposes hidden assumptions, catches logical gaps, and surface-tests claims that a single agent would silently accept. The literature on Constitutional AI and scalable oversight documents that debate can help a weaker mediator correctly evaluate outputs it could not produce on its own.

Connection to self-consistency

Debate is the structured cousin of self-consistency sampling (chain-of-thought with majority vote). Both elicit multiple reasoning paths. Debate is qualitatively richer because the paths react to each other — later arguments are more targeted than independent samples.

Forces

  • Quality. Highest of the three patterns — adversarial critique is the most reliable way to surface errors.
  • Latency. Slowest — KK rounds of back-and-forth plus synthesis. Unsuitable for latency-sensitive applications.
  • Cost. Highest — 2K+12K + 1 LLM calls minimum (two agents × K rounds + one mediator call).
  • Failure mode. Both agents may converge on the same wrong answer if the question has a compelling but incorrect consensus. The mediator needs to be robust to persuasion without evidence.

Pattern comparison

PatternRelative costRelative latencyOutput diversityPrimary failure mode
VotingO(N)O(N)Low (parallel)HighCorrelated errors
Role-basedO(K)O(K)Medium (sequential steps)MediumCascading planner error
DebateO(2K)O(2K)High (sequential rounds)HighConsensus on a wrong answer

NN = number of voters; KK = number of pipeline steps or debate rounds.

When to use which

Use voting for high-volume classification or factual QA where errors are independent and latency budget allows parallel calls. Use role-based for multi-step agentic tasks (coding, research, document generation) where each step has different requirements. Use debate for high-stakes, ambiguous, or controversial decisions where quality matters more than cost or speed.

These patterns describe who the agents are. The orthogonal axis is how control flows between sub-agents: deterministic sequential, parallel, and loop workflow agents that compose into hierarchies, versus an LLM deciding the routing at runtime. The deep dive covers the three primitives and their latency/cost/failure profiles:

Deep dive
Sub-Agent Types: Sequential, Parallel & Loop Agents
Includes runnable notebook

Exercise

You want three specialised agents — one for retrieval, one for reasoning, one for formatting — to jointly produce a research report. Which cooperation pattern fits best?

Need a hint?

Do these agents compete, vote, or complement each other with distinct roles?

Exercise

5 agents vote on whether a statement is factually correct: 3 say True, 2 say False. Under Condorcet's jury theorem, when does majority voting improve accuracy?

Need a hint?

Think about what the theorem assumes about individual agent accuracy.

Key takeaways

  • Multi-agent cooperation addresses the fundamental limits of any single agent: single point of failure, narrow context, and conflicting role requirements.
  • Voting-based cooperation aggregates NN independent answers; Condorcet's jury theorem guarantees accuracy approaches 1 as N→∞N \to \infty — provided agent errors are independent.
  • Role-based cooperation assigns planner, executor, critic, and summariser roles to separate agents; efficiency comes from specialisation and separation of concerns (the principle behind AutoGen and CrewAI).
  • Debate-based cooperation exposes hidden assumptions through adversarial argumentation; it produces the highest-quality outputs but at the highest cost and latency.
  • Choose the pattern based on the task's error-independence profile, latency budget, and whether quality or throughput dominates.

Related concepts

Concept neighbourhood

How this concept connects — click any node to jump there, or explore the whole concept map.

Builds onRelatedGo deeper
Multi-Agent Cooperation PatternsBuilding with LLMsAttention & TransformersReflection PatternsSafety, Registry & Adapta…Agents & Tool UseDeploying Agents in Produ…Sub-Agent Types: Sequenti…Agentic Analysis: A Metri…