Back to Blog

Agentic Debate: Enhancing LLM Reasoning through Multi-Agent Consensus

8 min read

Large Language Models (LLMs) are prone to hallucinations, logical slips, and cognitive biases. While techniques like Chain-of-Thought (CoT) help models break down reasoning steps, the single-model output is still susceptible to individual prompt variance.

The Agentic Debate pattern addresses this by placing multiple LLM agents in a structured debate. By critiquing, verifying, and debating their respective viewpoints over multiple rounds, agents resolve errors and arrive at a more robust consensus.

Agentic Debate Consensus SystemAgentic Debate Consensus System

The Debate Mechanism

A standard Agentic Debate workflow involves:

  1. Problem Input: The user presents a complex question (e.g., a logic puzzle or math problem).
  2. Independent Drafts: Multiple agents (with different system instructions or models) generate their initial answers.
  3. Debate Rounds: Each agent is shown the answers generated by the other agents and asked to update their own answer in response.
  4. Judge / Consensus: A final coordinator or judge LLM evaluates the debate and compiles the final answer.

Let A_i^{(r)} represent the answer of agent i in round r. In round r+1, the update is:

A_i^{(r+1)} = \text{LLM}\left(\text{Prompt}, A_1^{(r)}, A_2^{(r)}, \dots, A_n^{(r)}\right)

This iteration runs for a fixed number of rounds or until A_i^{(r+1)} \approx A_i^{(r)} for all agents.

Python Code: A Simple Agentic Debate System

Here is a Python script implementing a 2-agent debate loop:

import openai

def call_agent(model, system_prompt, user_prompt):
    client = openai.OpenAI()
    response = client.chat.completions.create(
        model=model,
        messages=[
            {"role": "system", "content": system_prompt},
            {"role": "user", "content": user_prompt}
        ],
        temperature=0.3
    )
    return response.choices[0].message.content

# Setup debate variables
question = "A bottle of water and a cup cost $1.10. The bottle costs $1.00 more than the cup. How much does the cup cost?"
agent_a_system = "You are Agent A, a logical reasoner. Solve the problem step-by-step."
agent_b_system = "You are Agent B, a critical mathematician. Analyze the problem step-by-step."

# Debate execution
# ans_a = call_agent("gpt-4o-mini", agent_a_system, question)
# ans_b = call_agent("gpt-4o-mini", agent_b_system, question)

Why It Works

Agentic debate is effective for several reasons:

  • Bias Reduction: Different agents highlight alternative interpretations, preventing the system from locking onto an initial incorrect assumption.
  • Cross-Verification: Errors in calculation or logic are frequently caught and corrected by peer models.
  • Self-Correction: Showing agents alternative answers encourages them to re-evaluate their logical paths.

Conclusion

The Agentic Debate pattern is a powerful method for improving LLM reasoning reliability. While it increases API consumption and latency, it significantly reduces errors, making it ideal for tasks where precision is critical.