A multi-agent AI debate system built with CrewAI that simulates structured debates on complex topics. This project demonstrates how AI agents can take opposing sides of an argument and have their performance evaluated by an impartial judge agent.
This debate system creates two opposing arguments on a given topic using a single debater agent that alternates perspectives, followed by evaluation from a judge agent. The system is designed to explore different viewpoints on controversial topics and provide balanced analysis.
Current Implementation: The system debates "Is AI a threat to humanity?" by generating supporting and opposing arguments, then having a judge evaluate both sides.
-
Debater Agent (
gpt-4o-mini)- Role: Knowledgeable debater on the specified topic
- Goal: Generate compelling arguments for both sides of the debate
- Tasks: Creates both proposer (supporting) and opposer (opposing) arguments
-
Judge Agent (
gpt-4o-mini)- Role: Impartial judge with expertise on the topic
- Goal: Evaluate the debate fairly and provide scoring
- Tasks: Analyzes both sides and provides comprehensive evaluation
- Python >=3.10 <3.14
- UV package manager
- OpenAI API key
- Install UV (if not already installed):
pip install uv- Navigate to project directory:
cd crew/debate- Install dependencies:
crewai install- Set up environment variables:
- Add your
OPENAI_API_KEYto the.envfile
- Add your
Execute the debate system from the project root:
crewai runThis will:
- Generate 10 supporting arguments for the motion (saved to
proposer.md) - Generate 10 opposing arguments against the motion (saved to
opposer.md) - Have the judge evaluate both sides and provide a comprehensive decision
To debate a different topic, modify the inputs in src/debate/main.py:
inputs = {
'topic': 'Your custom debate topic here',
}Train the crew for improved performance:
crewai train <n_iterations> <filename>Test the crew's performance:
crewai test <n_iterations> <eval_llm>Replay a specific task execution:
crewai replay <task_id>debate/
โโโ src/debate/
โ โโโ __init__.py
โ โโโ config/
โ โ โโโ agents.yaml # Agent configurations
โ โ โโโ tasks.yaml # Task definitions
โ โโโ tools/
โ โ โโโ __init__.py
โ โ โโโ custom_tool.py # Custom tool template
โ โโโ crew.py # Main crew orchestration
โ โโโ main.py # Entry point and execution logic
โโโ knowledge/
โ โโโ user_preference.txt # User context information
โโโ proposer.md # Generated supporting arguments
โโโ opposer.md # Generated opposing arguments
โโโ README.md # This file
debater:
role: "You are a debater with a nice amount of knowledge about the topic {topic}"
goal: "Debate the topic {topic}"
backstory: "You're a seasoned debater with a knack for debating the topic {topic}. Known for your ability to debate the topic in a clear and concise manner."
model: gpt-4o-mini
judge:
role: "You are a judge with a nice amount of knowledge about the topic {topic}"
goal: "Judge the debate between the debater and the opponent"
backstory: "You're a meticulous judge with a keen eye for detail. You are just and unbiased."
model: gpt-4o-miniThe system includes three main tasks:
- Proposer Task: Generates 10 supporting arguments
- Opposer Task: Generates 10 opposing arguments
- Decider Task: Judges both sides and provides comprehensive evaluation
The system generates 10 bullet points supporting the motion, covering aspects like:
- Augmentation of human abilities
- Economic growth and innovation
- Healthcare improvements
- Global challenge solutions
- Safety enhancements
The system generates 10 bullet points opposing the motion, covering concerns like:
- Exponential AI growth risks
- Autonomous weaponry concerns
- Job displacement issues
- Privacy and surveillance threats
- Existential risks
The judge provides:
- Scores for both sides
- Reasoning for the scores
- Overall conclusion
- Recommendations for the debate
Extend functionality by creating custom tools in the tools/ directory:
from crewai.tools import BaseTool
from typing import Type
from pydantic import BaseModel, Field
class MyCustomToolInput(BaseModel):
argument: str = Field(..., description="Description of the argument.")
class MyCustomTool(BaseTool):
name: str = "Name of my tool"
description: str = "Tool description"
args_schema: Type[BaseModel] = MyCustomToolInput
def _run(self, argument: str) -> str:
# Implementation goes here
return "Tool output"Edit the YAML configuration files to:
- Change agent personalities and expertise
- Adjust LLM models and parameters
- Modify task descriptions and outputs
- Add new debate formats
The system includes a knowledge base (knowledge/user_preference.txt) that can be expanded with:
- Domain-specific information
- User preferences and context
- Historical debate data
- Expert opinions and research
The system works well with controversial topics such as:
- "Is AI a threat to humanity?" (default)
- "Should social media be regulated?"
- "Is remote work better than office work?"
- "Should genetic engineering be allowed?"
- "Is cryptocurrency the future of money?"
The crew uses sequential processing to ensure:
- Supporting arguments are generated first
- Opposing arguments are created independently
- Judge evaluation considers both perspectives
Enable detailed logging to see:
- Agent reasoning processes
- Task execution steps
- Decision-making chains
- Performance metrics
Integrate external knowledge sources to enhance argument quality and factual accuracy.
Modify the training and testing functions in main.py to experiment with:
- Different topics and complexity levels
- Various evaluation criteria
- Multiple debate formats
- Different LLM models
- Model Selection: Currently uses
gpt-4o-minifor cost-effectiveness - Sequential Processing: Ensures logical flow of arguments
- Output Files: Saves results for analysis and comparison
- Error Handling: Robust exception management for reliable execution
To extend this debate system:
- Add New Agent Types: Create specialized roles (researcher, fact-checker, audience)
- Implement New Debate Formats: Add parliamentary, town hall, or academic styles
- Enhance Evaluation: Create more sophisticated scoring systems
- Add Real-time Features: Implement live debate capabilities
- Integrate External Data: Connect to research databases and current events
This project is part of the larger "Using CrewAI and Multiple LLMs" repository and follows the same licensing terms.
This project demonstrates:
- Multi-agent system design patterns
- Structured debate simulation
- AI-powered argument generation
- Automated evaluation systems
- CrewAI framework implementation
Perfect for learning about AI agents, debate analysis, and collaborative AI systems.
Current Status: The system successfully generates balanced arguments on AI's impact on humanity and provides impartial evaluation. Ready for extension with additional topics and enhanced evaluation criteria.