Overview
TheDebateWithJudge module provides a sophisticated debate architecture with self-refinement through a judge agent. This system enables two agents (Pro and Con) to debate a topic, with a Judge agent evaluating their arguments and providing refined synthesis. The process repeats for N rounds to progressively refine the answer.
Installation
Architecture
Key Concepts
Attributes
Optional[Agent]
default:"None"
The agent arguing in favor (Pro position). Not required if using
agents list or preset_agents.Optional[Agent]
default:"None"
The agent arguing against (Con position). Not required if using
agents list or preset_agents.Optional[Agent]
default:"None"
The judge agent that evaluates arguments and provides synthesis. Not required if using
agents list or preset_agents.Optional[List[Agent]]
default:"None"
A list of exactly 3 agents in order:
[pro_agent, con_agent, judge_agent]. Takes precedence over individual agent parameters.bool
default:"False"
If
True, creates default Pro, Con, and Judge agents automatically with optimized system prompts.int
default:"3"
Maximum number of debate rounds to execute.
str
default:"str-all-except-first"
Format for the output conversation history.
bool
default:"True"
Whether to enable verbose logging.
str
default:"gpt-5.4"
The model name to use for preset agents.
Initialization Options
TheDebateWithJudge class supports three ways to configure agents:
Option 1: Preset Agents (Simplest)
Use built-in agents with optimized system prompts for debates:Option 2: List of Agents
Provide a list of exactly 3 agents (Pro, Con, Judge):Option 3: Individual Agent Parameters
Provide each agent separately:Methods
run()
Executes the debate with judge refinement process for a single task and returns the refined result.task(str): The initial topic or question to debate
output_type
Process Flow:
- Task Validation: Validates that the task is a non-empty string
- Agent Initialization: Initializes all three agents with their respective roles and the initial task context
- Multi-Round Execution: For each round (up to
max_loops):- Pro agent presents an argument in favor
- Con agent presents a counter-argument
- Judge agent evaluates both arguments and provides synthesis
- Judge’s synthesis becomes the topic for the next round
- Result Formatting: Returns the final result formatted according to
output_type
ValueError: If task is None or empty. (Invalid agent configuration ormax_loops < 1raiseValueErrorat construction time, in__init__, not inrun().)
batched_run()
Executes the debate for multiple tasks sequentially.tasks(List[str]): List of topics or questions to debate
get_conversation_history()
Get the full conversation history from the debate.get_final_answer()
Get the final refined answer from the judge.Output Types
Theoutput_type parameter controls how the conversation history is formatted:
Usage Examples
Quick Start with Preset Agents
Policy Debate with Custom Agents
Using Agent List
Batch Processing Multiple Topics
Business Strategy Debate with Conversation History
Best Practices
Choosing an Initialization Method: Use
preset_agents=True for quick prototyping, agents=[...] list when you have agents from external sources, and individual parameters for maximum control.Loop Configuration: Use 2-3 loops for most topics and 4-5 loops for complex, multi-faceted topics. More loops allow for deeper refinement but increase execution time.
Output Format: Use
"str-all-except-first" for readable summaries (default), "dict" for structured analysis, "list" for conversation inspection, and "str" for complete history.