Skip to content

dborkakoti/multi-agent-debate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent Debate System

A production-oriented, multi-round philosophical debate system coordinating multiple agents (Socrates/Plato/Aristotle) with optional tool use (search/calculation/time) to explore complex questions through structured argumentation.

Table of Contents


Overview

This system orchestrates debates between AI agents embodying classical philosophers. Each run produces a transcript across multiple rounds, optionally ending with a synthesized summary.

What it supports:

  • Multi-agent, multi-round discussions (agent order can vary per round)
  • Persona-driven responses (Socratic questioning, philosophical framing, pragmatic recommendations)
  • Optional tool usage (web search, calculator evaluation, date/time)
  • Optional persistent memory (JSON-backed)

Key features

Multi-agent architecture

  • Socrates Agent: Clarifying questions / Socratic method (premises, definitions, contradictions)
  • Plato Agent: Philosophical context and frameworks (theory, interpretations, conceptual scaffolding)
  • Aristotle Agent: Practical/action-oriented reasoning (may invoke tools where enabled)
  • Summary Agent (optional): Consolidated synthesis after the final round

Tool system (optional / configurable)

  • Web search integration (DuckDuckGo)
  • Safe calculator-style evaluation for math expressions
  • Current date/time retrieval
  • Heuristics for tool triggering + query extraction (where enabled)

Architecture & operations

  • Modular package structure with separation of concerns
  • YAML configuration for models, agents, and tools
  • Multiple model backends (Ollama / Transformers)
  • Persistent memory via JSON storage
  • Basic retry/error-handling hooks for resilience

Architecture

Component flow

flowchart TB
  %% Interfaces
  subgraph UI[User Interfaces]
    CLI["CLI<br/>(debate_system.interfaces.cli)"]
    WEB["Streamlit Web UI<br/>(debate_system/interfaces/web.py)"]
    API["Python API<br/>(debate_system/interfaces/api.py)"]
  end

  %% Configuration
  subgraph CFG[Configuration Layer]
    CM["ConfigManager<br/>(debate_system/core/config.py)"]
    SET["settings.yaml"]
    PER["personas.yaml"]
  end

  %% Orchestration
  subgraph ORCH[Orchestration Layer]
    O["Orchestrator<br/>(debate_system/core/orchestrator.py)"]
  end

  %% Agents
  subgraph AG[Agent Layer]
    BA["BaseAgent<br/>(debate_system/agents/base.py)"]
    S["SocratesAgent"]
    P["PlatoAgent"]
    A["AristotleAgent"]
    SUM["SummaryAgent<br/>(optional)"]
  end

  %% Memory + Tools
  subgraph MT[Memory + Tools]
    MS["MemoryStore<br/>(debate_system/core/memory_store.py)"]
    T["Tools<br/>(debate_system/core/tools.py)"]
  end

  %% Inference
  subgraph INF[Model Inference Layer]
    MM["ModelManager<br/>(debate_system/inference/model_loader.py)"]
    OL["Ollama backend"]
    TR["Transformers backend"]
  end

  %% Wiring
  CLI --> CM
  WEB --> CM
  API --> CM

  CM --> SET
  CM --> PER
  CM --> O

  O --> S
  O --> P
  O --> A
  O -. enable_summary .-> SUM

  S --> BA
  P --> BA
  A --> BA
  SUM --> BA

  O <--> MS
  A -. optional tool calls .-> T

  BA --> MM
  MM --> OL
  MM --> TR
Loading

Debate turn sequence

sequenceDiagram
  autonumber
  participant U as User
  participant UI as CLI/Web/API
  participant C as ConfigManager
  participant O as Orchestrator
  participant M as MemoryStore
  participant AG as Agents (Socrates/Plato/Aristotle)
  participant L as ModelManager/Backend

  U->>UI: Prompt
  UI->>C: Load settings/personas
  C->>O: Start debate (rounds=N, order may vary)
  O->>M: Load/prepare memory + history

  Note over O,AG: For each round, agent order may be randomized
  loop For each agent turn in chosen order
    O->>AG: respond(history, memory)
    AG->>L: generate(prompt)
    L-->>AG: text
    AG-->>O: turn
    O->>M: update memory/history
  end

  O-->>UI: Full transcript (+ optional summary)
  UI-->>U: Display results
Loading

Design patterns (implementation-level)

  • Singleton: ModelManager (single model instance)
  • Factory: Backend selection based on config
  • Template Method: BaseAgent with customizable methods
  • Strategy: Different backends implementing same interface
  • Observer: Memory updates tracked across turns
  • Facade: ConfigManager simplifies YAML access
  • Chain of Responsibility: Agent turns in sequence

Quickstart

# Clone repository
git clone https://github.com/mayurmadnani/multi-agent-debate
cd multi-agent-debate

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
pip install -e .

Run an example debate:

python -m debate_system.interfaces.cli "What is the meaning of life?" --rounds 3

Usage

Notes:

  • Agent ordering may vary per round to simulate debate dynamics.
  • Enable/disable tools and summary behavior via configuration (see configs/).

CLI

Interactive mode:

python -m debate_system.interfaces.cli

Single prompt:

python -m debate_system.interfaces.cli "What is the meaning of life?" --rounds 3

Discover supported flags/options:

python -m debate_system.interfaces.cli --help

Web UI (Streamlit)

streamlit run debate_system/interfaces/web.py

Alternative invocation:

python -m streamlit run debate_system/interfaces/web.py

Python API

from debate_system.interfaces.api import DebateAPI

api = DebateAPI()
result = api.ask("What is the nature of consciousness?", rounds=3)

for entry in result["history"]:
  print(f"{entry['speaker']}: {entry['content']}")

Testing

pytest -q

Project structure

debate_system/
  agents/        # Agent implementations (Socrates/Plato/Aristotle/Summary)
  core/          # Config, memory, tools, orchestration
  inference/     # Model manager + backend implementations
  interfaces/    # CLI, Web UI, API wrapper
configs/         # YAML settings (models/personas/tools)
data/            # Default location for persisted memory (if enabled)
tests/           # Unit tests (tools/agents/etc.)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 87.1%
  • Python 12.9%