Week 15 • Day 4Week 15
Day 4:Adversarial Debate & Evaluator-Optimizer (Generator-Critic) Loops
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Day 4: Adversarial Debate & Evaluator-Optimizer (Generator-Critic) Loops
1. First-Principles Pattern: Separation of Generation and Verification
When an LLM generates a production remediation command (e.g., SQL migration or Kubernetes patch) and is asked in the same prompt "Is your command safe?", confirmation bias causes the model to agree with itself >90% of the time.
In an Evaluator-Optimizer (Generator-Critic) Loop:
- Generator Agent (
RemediationGenerator): Proposes a candidate remediation plan . - Adversarial Critic Agent (
SecurityAndSRECritic): Operates with a strict adversarial rubric checking for:- Destructive commands (
DROP TABLE,DELETE FROMwithoutWHERE,kubectl delete namespace,rm -rf) - Missing rollback instructions
- Missing blast-radius limits (e.g., missing
--max-unavailableorLIMITclause)
- Destructive commands (
- Iterative Refinement: If the Critic rejects with structured violation feedback , the Generator produces up to iterations.
In Simple English: Two Brains Reviewing Each Other (Generator-Critic Loop)
Think of writing an important essay:
- Generator (Writer): Drafts the answer or code patch quickly.
- Critic / Evaluator (Editor): Inspects ONLY against a strict checklist ("Does the SQL have a LIMIT clause? Did every claim cite a log line? Are there syntax errors?").
- IfCritic says
PASS, ship immediately! - If Critic finds specific bugs, send exact line-level feedback back to Generator for at most 2–3 revision loops (preventing endless perfectionist loops!).
- IfCritic says