Skip to main content
Multi-Agent Debate is a workflow pattern that simulates a multi-turn discussion between different agents. This pattern is particularly useful for problem-solving tasks where multiple perspectives can lead to better solutions.

Overview

The debate workflow typically involves:
  • Solver Agents (Debaters): Generate and exchange their answers, arguing from different perspectives
  • Aggregator Agent (Moderator): Collects and evaluates the arguments, deciding when a correct answer has been reached
This pattern is inspired by research showing that multi-agent debate can improve reasoning accuracy in Large Language Models (reference: “Encouraging Divergent Thinking in Large Language Models through Multi-Agent Debate”, EMNLP 2024).

Architecture

Implementation

Step 1: Create Debater Agents

Step 2: Create Moderator Agent

The moderator evaluates the debate and decides when a correct answer has been found:
%s

Step 3: Define Structured Output for Judgment

Use a structured output class to capture the moderator’s decision:

Step 4: Implement the Debate Loop

Complete Example

Here’s a complete, runnable example:

Variations

Multiple Debaters

You can extend the pattern to include more than two debaters:

Debate Without Moderator

For simpler scenarios, you can run a debate without a moderator and let the debaters reach consensus:
  • MsgHub - Message broadcasting for multi-agent conversations
  • Pipeline - Sequential and parallel agent execution
  • Handoffs - State-driven routing and transfer between agents
  • Routing - Classify and route to specialist agents
  • Structured Output - Extracting structured data from agent responses