Debate Pattern

Source: examples/patterns/debate_pattern.py

Introduction

Multiagent Debate shows how adversarial dialogue can improve answer quality, AutoGen provides practical orchestration motifs, and Human-AI collaboration by design situates debate outputs within reviewable decision pipelines. This example runs a proposer-vs-critic debate pattern over shared tool/runtime interfaces.

Technical Implementation

  1. Configure Tracer with JSONL + console output so each run emits machine-readable traces and lifecycle logs.

  2. Build the runtime surface (public APIs only) and execute DebatePattern.run(...) with a fixed request_id.

  3. Configure and invoke Toolbox integrations (core/script/MCP/callable) before assembling the final payload.

  4. Print a compact JSON payload including trace_info for deterministic tests and docs examples.

        flowchart LR
    A["Input prompt or scenario"] --> B["main(): runtime wiring"]
    B --> C["DebatePattern.run(...)"]
    C --> D["position agents debate before synthesis"]
    C --> E["Tracer JSONL + console events"]
    D --> F["ExecutionResult/payload"]
    E --> F
    F --> G["Printed JSON output"]
    
 1from __future__ import annotations
 2
 3import json
 4from pathlib import Path
 5
 6from design_research_agents import LlamaCppServerLLMClient, Toolbox, Tracer
 7from design_research_agents.patterns import DebatePattern
 8
 9
10def main() -> None:
11    """Run one debate round with final judge verdict."""
12    # Fixed request id keeps traces and docs output deterministic across runs.
13    request_id = "example-workflow-debate-design-001"
14    tracer = Tracer(
15        enabled=True,
16        trace_dir=Path("artifacts/examples/traces"),
17        enable_jsonl=True,
18        enable_console=True,
19    )
20    # Run the debate pattern using public runtime surfaces. Using this with statement will automatically shut down
21    # the managed client and tool runtime when the example is done.
22    with Toolbox() as tool_runtime, LlamaCppServerLLMClient() as llm_client:
23        workflow = DebatePattern(
24            llm_client=llm_client,
25            tool_runtime=tool_runtime,
26            max_rounds=1,
27            tracer=tracer,
28        )
29        result = workflow.run(
30            prompt=(
31                "Should an engineering design team prioritize local models over hosted APIs when "
32                "reviewing sensitive prototype telemetry?"
33            ),
34            request_id=request_id,
35        )
36
37    # Print the results
38    summary = result.summary()
39    print(json.dumps(summary, ensure_ascii=True, indent=2, sort_keys=True))
40
41
42if __name__ == "__main__":
43    main()

Expected Results

Run Command

PYTHONPATH=src python3 examples/patterns/debate_pattern.py

Example output shape (values vary by run):

{
  "success": true,
  "final_output": "<example-specific payload>",
  "terminated_reason": "<string-or-null>",
  "error": null,
  "trace": {
    "request_id": "<request-id>",
    "trace_dir": "artifacts/examples/traces",
    "trace_path": "artifacts/examples/traces/run_<timestamp>_<request_id>.jsonl"
  }
}

References