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
 6import design_research_agents as drag
 7
 8
 9def main() -> None:
10    """Run one debate round with final judge verdict."""
11    # Fixed request id keeps traces and docs output deterministic across runs.
12    request_id = "example-workflow-debate-design-001"
13    tracer = drag.Tracer(
14        enabled=True,
15        trace_dir=Path("artifacts/examples/traces"),
16        enable_jsonl=True,
17        enable_console=True,
18    )
19    # Run the debate pattern using public runtime surfaces. Using this with statement will automatically shut down
20    # the managed client and tool runtime when the example is done.
21    with drag.Toolbox() as tool_runtime, drag.LlamaCppServerLLMClient() as llm_client:
22        workflow = drag.DebatePattern(
23            llm_client=llm_client,
24            tool_runtime=tool_runtime,
25            max_rounds=1,
26            tracer=tracer,
27        )
28        result = workflow.run(
29            prompt=(
30                "Should an engineering design team prioritize local models over hosted APIs when "
31                "reviewing sensitive prototype telemetry?"
32            ),
33            request_id=request_id,
34        )
35
36    # Print the results
37    summary = result.summary()
38    print(json.dumps(summary, ensure_ascii=True, indent=2, sort_keys=True))
39
40
41if __name__ == "__main__":
42    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#