Day 03 Applied Skills

The Debate Pattern: AI Reviewing AI for Better Outputs

The debate pattern assigns one agent to generate and another to critique — then iterates until the output meets a quality bar. This produces significantly

~1 hour Hands-on Precision AI Academy

Today's Objective

Learn the core concepts of The Debate Pattern: AI Reviewing AI for Better Outputs and apply them in practical exercises.

01

Why Debate Produces Better Outputs

Single-agent outputs have a consistent blind spot: the agent does not know what it does not know. A critic agent catches logical errors, unsupported claims, and missing considerations that the original generator missed.

debate.js
debate.js
import Anthropic from '@anthropic-ai/sdk';
import * as dotenv from 'dotenv';
dotenv.config();

const client = new Anthropic();

async function callAgent(system, message) {
  const response = await client.messages.create({
    model: 'claude-opus-4-5',
    max_tokens: 2048,
    system,
    messages: [{ role: 'user', content: message }]
  });
  return response.content[0].text;
}

const GENERATOR = 'You write thorough, well-structured analysis. Be specific and concrete.';
const CRITIC = `You are a rigorous critic. Review the work and identify:
1. Factual errors or unsupported claims
2. Missing important considerations
3. Logical weaknesses
4. Sections that are vague or generic

Be specific about each issue. Rate severity: [HIGH/MEDIUM/LOW].
End with: PASS (if quality is acceptable) or REVISE (if it needs work).`;
const REVISER = 'You improve drafts based on critique feedback. Address each HIGH and MEDIUM issue specifically.';

async function debateLoop(task, maxRounds = 3) {
  let currentOutput = await callAgent(GENERATOR, task);
  console.log('Initial draft generated.');
  
  for (let round = 1; round <= maxRounds; round++) {
    console.log(`
Critique round ${round}...`);
    
    const critique = await callAgent(
      CRITIC,
      `Review this work:

${currentOutput}`
    );
    
    console.log('Critique summary:', critique.slice(0, 200) + '...');
    
    // Check if critic approves
    if (critique.includes('PASS')) {
      console.log('Quality check passed!');
      break;
    }
    
    if (round < maxRounds) {
      console.log('Revising...');
      currentOutput = await callAgent(
        REVISER,
        `Original task: ${task}

Current version:
${currentOutput}

Critique:
${critique}

Revise to address the HIGH and MEDIUM issues.`
      );
    }
  }
  
  return currentOutput;
}

// Example: write a persuasive argument
const result = await debateLoop(
  'Write a persuasive case for why small businesses should adopt AI tools in 2026'
);
console.log('
FINAL OUTPUT:
', result);

Supporting References & Reading

Go deeper with these external resources.

Docs
The Debate Pattern: AI Reviewing AI for Better Outputs Official documentation for multi agent.
GitHub
The Debate Pattern: AI Reviewing AI for Better Outputs Open source examples and projects for The Debate Pattern: AI Reviewing AI for Better Outputs
MDN
MDN Web Docs Comprehensive web technology reference

Day 3 Checkpoint

Before moving on, confirm understanding of these key concepts:

Continue To Day 4
Day 4 of the Multi-Agent Systems course