DebateGraph is an intelligent Multi-Agent System (MAS) that simulates structured debates between opposing AI personas. Built using LangGraph and LangChain, it orchestrates a strictly controlled workflow where agents maintain memory, adhere to turn-based constraints, and submit to a final verdict by an AI Judge.
- Dual-Agent Architecture: Simulates a clash between a Scientist (Empirical/Logic-driven) and a Philosopher (Ethics/Value-driven).
- Structured Workflow: Enforces a strict 8-round debate format using a Directed Acyclic Graph (DAG).
- State Management: Uses
LangGraphto manage conversation state, turn history, and "next speaker" logic. - Smart Memory: Agents receive "sliced" context (only the relevant previous argument) to prevent context bloating.
- AI Judge: A specialized node analyzes the full transcript to declare a winner based on logical coherence and persuasion.
- High-Performance Inference: Optimized for Groq API (Llama 3.3) for lightning-fast responses without rate-limit bottlenecks.
- Audit Logging: Automatically generates timestamped JSON logs for every state transition and argument.
- Orchestration: LangGraph (StateGraph)
- LLM Framework: LangChain Core
- Inference Engine: Groq API (Llama-3.3-70b-versatile)
- Language: Python 3.10+
- Utilities: Pydantic (Validation), Python-Dotenv (Config)
The system operates as a State Machine with the following nodes:
- UserInput: Initializes the debate topic.
- Controller (Edge): Checks round count. If
< 8, routes to the next speaker; if8, routes to Judge. - Agent Nodes (A/B): Generates arguments using specific system prompts (Scientist vs. Philosopher).
- Memory Node: Updates the conversation history and flips the "turn" flag.
- Judge Node: Critical analysis of the full debate logic and declares a winner.
(Note: Diagram is generated automatically on the first run)
-
Clone the Repository
git clone [https://github.com/Nikhil-Codehub/DebateGraph.git](https://github.com/Nikhil-Codehub/DebateGraph.git) cd DebateGraph -
Create a Virtual Environment
python -m venv venv # Windows venv\Scripts\activate # Mac/Linux source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Set up Environment Variables Create a
.envfile in the root directory:GROQ_API_KEY=gsk_your_groq_api_key_here
Run the main script via CLI:
python main.py