Debate
Three agents: one argues for a proposition, one against, a neutral judge picks the stronger side. Adversarial setups surface considerations a single agent glosses over — the disagreement is the feature.
Showcase — Debate
Three agents: one argues for a proposition, one against, a neutral judge picks the stronger side. Adversarial setups surface considerations a single agent glosses over — the disagreement is the feature.
Run
bash bootstrap-secrets.sh # reads ../../../../.env, writes secrets/
docker compose up --build # default: PROVIDER=openai
Open http://localhost:3000. Gemini: PROVIDER=gemini docker compose up --build.
What's where
backend/ai_openai.py/backend/ai_gemini.py— for / against / judge agents.frontend/app/page.tsx— proposition box; both sides + verdict.
Stop
docker compose down
Run locally
Download the project as a ZIP and run it with Docker. Brings up a FastAPI backend + Next.js frontend on localhost:3000.
unzip debate.zip
cd debate
bash bootstrap-secrets.sh # one-time: pulls API keys into ./secrets
docker compose up --build # default provider: openai
# or: PROVIDER=gemini docker compose up --build
Type some input, pick a provider, and run the same code shown in Source against the live API. Sign-in required.
The same modules the Run button hits. The whole project (frontend, Dockerfile, compose) is in the ZIP under README.
backend/ai_openai.py
"""Showcase 3 (OpenAI): a debate with a judge.
Three agents again, arranged as adversaries plus a referee: one argues for a
proposition, one against, and a neutral judge decides which side was stronger.
Adversarial multi-agent setups surface considerations a single agent glosses
over — the disagreement is the feature.
"""
from openai import OpenAI
_client = OpenAI()
_MODEL = "gpt-5.4-nano"
def _agent(system: str, user: str) -> str:
return _client.responses.create(model=_MODEL, instructions=system, input=[{"role": "user", "content": user}]).output_text
def run(proposition: str) -> str:
p = proposition.strip()
if not p:
return "Enter a proposition to debate (e.g. 'Remote work is better for productivity')."
pro = _agent("You argue FOR the proposition in 3-4 sentences. Persuasive but honest.", p)
con = _agent("You argue AGAINST the proposition in 3-4 sentences. Persuasive but honest.", p)
verdict = _agent(
"You are a neutral judge. Given a proposition and both sides, say which argument is "
"stronger and why, in 2-3 sentences. Don't just split the difference.",
f"PROPOSITION: {p}\n\nFOR:\n{pro}\n\nAGAINST:\n{con}",
)
return f"FOR:\n{pro}\n\nAGAINST:\n{con}\n\nJUDGE:\n{verdict}"
backend/ai_gemini.py
"""Showcase 3 (Gemini): a debate with a judge.
Same for/against/judge structure, on Gemini.
"""
import os
from google import genai
from google.genai import types
_client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
_MODEL = "gemini-3.1-flash-lite"
def _agent(system: str, user: str) -> str:
r = _client.models.generate_content(
model=_MODEL,
contents=[types.Content(role="user", parts=[types.Part(text=user)])],
config=types.GenerateContentConfig(system_instruction=system),
)
return r.text or ""
def run(proposition: str) -> str:
p = proposition.strip()
if not p:
return "Enter a proposition to debate (e.g. 'Remote work is better for productivity')."
pro = _agent("You argue FOR the proposition in 3-4 sentences. Persuasive but honest.", p)
con = _agent("You argue AGAINST the proposition in 3-4 sentences. Persuasive but honest.", p)
verdict = _agent(
"You are a neutral judge. Given a proposition and both sides, say which argument is "
"stronger and why, in 2-3 sentences. Don't just split the difference.",
f"PROPOSITION: {p}\n\nFOR:\n{pro}\n\nAGAINST:\n{con}",
)
return f"FOR:\n{pro}\n\nAGAINST:\n{con}\n\nJUDGE:\n{verdict}"
Project files
.gitignoreREADME.es.mdREADME.mdbackend/Dockerfilebackend/ai_gemini.pybackend/ai_openai.pybackend/main.pybackend/requirements.txtbootstrap-secrets.shdocker-compose.ymlfrontend/Dockerfilefrontend/app/layout.tsxfrontend/app/page.tsxfrontend/next.config.tsfrontend/package.jsonfrontend/tsconfig.json