惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
V
V2EX
博客园 - 【当耐特】
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
量子位
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
月光博客
月光博客
I
InfoQ
WordPress大学
WordPress大学
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
小众软件
小众软件
罗磊的独立博客
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
🚀I Built a Multi-Agent AI Debate Arena with LangGraph and...
Sripadh Suji · 2026-04-30 · via DEV Community

Sripadh Sujith

Ever wondered what happens when you let AI argue with itself?

I built AI Debate Arena — a terminal app where four AI agents (a moderator, a pro debater, a con debater, and a judge) run a full structured debate on any topic you give them, powered by LangGraph and Groq.

Here's how it works and what I learned building it.


🧠 The Concept

The idea is simple: instead of one AI giving you a balanced answer on a topic, what if multiple agents each had a role and a perspective — and had to argue, rebut, and decide?

Four agents, one state machine:

Agent Job
Moderator Introduces the topic, sets the rules, picks who goes first
Pro Argues for the topic every round
Con Rebuts and argues against the topic every round
Judge Reviews the full debate history and declares a winner

🔧 The Stack

  • LangGraph — for the state machine / agent orchestration
  • Groq + llama-3.1-8b-instant — for fast LLM inference
  • Rich — for the live typewriter-style terminal UI

🗂️ Project Structure

I split the project across 4 files for clean separation of concerns:

debate-arena/
├── main.py           # Entry point, user input, terminal display
├── agents.py         # State definition, LLM, agent functions
├── connections.py    # Graph nodes, edges, routing logic
└── prompts.py        # All prompt templates

Enter fullscreen mode Exit fullscreen mode


🖥️ Terminal UI with Rich

After the graph finishes, the full history list is played back with a live typewriter effect using Rich:

def typewriter_panel(role, content):
    colors = {
        "moderator": "cyan",
        "pro": "green",
        "con": "red",
        "judge": "magenta"
    }
    text = Text()
    with Live(Panel(text, title=role.upper(), border_style=colors.get(role, "white")), refresh_per_second=30) as live:
        for char in content:
            text.append(char)
            sleep(0.005)
            live.update(Panel(text, title=role.upper(), border_style=colors.get(role, "white")))

Enter fullscreen mode Exit fullscreen mode

Each role gets its own colour — cyan for the moderator, green for pro, red for con, magenta for the judge.


🧪 Running It

pip install -r requirements.txt
python main.py

Enter fullscreen mode Exit fullscreen mode

Enter the topic: AI will replace software engineers
Enter maximum rounds: 3

Enter fullscreen mode Exit fullscreen mode

Then watch the debate unfold in your terminal.


💡 What I Learned

LangGraph's conditional edges are powerful. Once I understood that routing is just a function that returns a string key, wiring up complex agent flows became intuitive.

Shared state is everything. All four agents read from and write to the same State dict. Keeping it well-defined upfront saved a lot of debugging later.

Prompt discipline matters. Telling each agent to "avoid repetition" and "rebut the previous argument" in the prompt made a real difference in output quality.

Groq is fast. Running 3 rounds with 4 agents means 6+ LLM calls — Groq handled this without any noticeable delay.


🔮 What's Next

  • Save debate transcripts to a file
  • Swap in different models per agent
  • Build a web UI with Flask or Streamlit
  • Add a third "neutral" debater

The full code is on GitHub: github.com/Sripadh-Sujith/debate-arena

If you build something on top of this or have ideas for improvements, drop them in the comments. Happy to discuss!

Thank You💖