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:

  1. Generator Agent (RemediationGenerator): Proposes a candidate remediation plan y(t)y^{(t)}.
  2. Adversarial Critic Agent (SecurityAndSRECritic): Operates with a strict adversarial rubric R(y(t))R(y^{(t)}) checking for:
    • Destructive commands (DROP TABLE, DELETE FROM without WHERE, kubectl delete namespace, rm -rf)
    • Missing rollback instructions
    • Missing blast-radius limits (e.g., missing --max-unavailable or LIMIT clause)
  3. Iterative Refinement: If the Critic rejects y(t)y^{(t)} with structured violation feedback f(t)f^{(t)}, the Generator produces y(t+1)=G(x,y(t),f(t))y^{(t+1)} = G(x, y^{(t)}, f^{(t)}) up to Tmax⁡T_{\max} 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!).