Architecture
An LLM evaluation control plane treats evaluation as an automated release and incident-prevention gate rather than a static leaderboard—connecting golden slice datasets, deterministic schema/permission assertions, human-calibrated pairwise LLM judges, statistical confidence bounds, and live telemetry drift triggers into one enforceable promote-or-rollback policy across models and prompts.
Teams commonly stall either by eyeballing a dozen cherry-picked vibe prompts before launching or by paying massive LLM-judge compute over thousands of requests that deterministic unit assertions could validate in 2 ms. A disciplined control plane routes every artifact (checkpoint upgrade, system prompt edit, retriever index bump, tool schema modification) through layered verifiers where deterministic invariants gate critical failures with zero false positives, statistical confidence intervals separate signal from stochastic variance, and sampled production traces replenish regression datasets whenever users abandon, thumbs-down, or trigger fallbacks.
1. Stratified Four-Layer Evaluator Funnel
- Layer 1 — Deterministic Programmatic Invariants (
< 2 ms): JSON Schema validation, allowed URL/enum bounds, arithmetic totals, non-empty retrieved chunk verification, forbidden regex/PII checks, and unit-tested tool-call preconditions. Never delegate exact software invariants to a probabilistic judge. - Layer 2 — Grounded Claim & Citation Verification: Maps atomic assertions in model answers strictly against retrieved context chunks using fast NLI models or exact substring span validation before permitting publication.
- Layer 3 — Debiased Pairwise Judge (
Position-Swapped): Compares Candidate vs Production Baseline across rubric dimensions while randomly permuting(A, B)order across two independent runs—discarding tied or inconsistent flips to defeat primary-position and verbosity bias. - Layer 4 — Severity & Cohort Gate: Separates aggregate pass rate (
>= 94%) from critical zero-tolerance failures (0cross-tenant leaks,0unsafe medical/financial directives,<= 1%schema drops) across tail cohorts (multilingual,long-context > 32k,edge refusals).
2. Statistical Significance & Judge Agreement Math
When promoting prompts on N = 200 test cases, naive differences (84% -> 87%) fall well inside sampling noise unless checked with a paired difference / McNemar test or 95% Wilson Score Confidence Interval:
Require Cohen's Kappa agreement against human domain graders across 50–100 calibrated holdout items before trusting an LLM judge inside automated CI/CD merges.
| Gate Dimension | Target Threshold | Measurement Cost | Blocking Action on Failure |
|---|---|---|---|
| Critical Policy / Safety Slice | 100% pass (0 critical escapes) | Minimal (~100 deterministic + red probes) | Hard CI block + security alert |
| Core Workflow Task Success | Lower 95% Wilson CI > Baseline - 1.5% | Medium (300–500 golden cases) | Reject promotion; output cohort diff |
| Judge Calibration Agreement | Cohen's vs SME labels | Offline weekly check (100 samples) | Demote auto-judge to human triage |
| Online Canary Regression | Fallback / abort spike < +0.8% delta | Real-time sampled traces | Automated canary traffic rollback |
3. Paired CI Release Gate & Position-Debiased Harness in Python
pythonimport mathfrom dataclasses import dataclass@dataclass(frozen=True)class GateVerdict:approved: boolreason: strpass_rate: floatci_lower_95: floatdef wilson_lower_bound(wins: int, total: int, z: float = 1.96) -> float:"""Compute conservative 95% lower confidence bound guarding small sample flips."""if total <= 0:return 0.0p_hat = wins / totaldenom = 1.0 + (z * z) / totalcenter = p_hat + (z * z) / (2.0 * total)margin = z * math.sqrt((p_hat * (1.0 - p_hat) + (z * z) / (4.0 * total)) / total)return max(0.0, (center - margin) / denom)def position_debiased_win(score_ab: str, score_ba: str) -> str:"""Accept judge win only when order-swapped runs agree consistently."""if score_ab == "CANDIDATE" and score_ba == "CANDIDATE":return "CANDIDATE"if score_ab == "BASELINE" and score_ba == "BASELINE":return "BASELINE"return "TIE_OR_POSITION_BIAS"def evaluate_release_gate(critical_failures: int,candidate_wins: int,total_cases: int,baseline_lower_ci: float,) -> GateVerdict:"""Enforce zero critical severity escapes plus statistical non-regression."""if critical_failures > 0:return GateVerdict(False, f"Blocked by {critical_failures} critical failure(s)", 0.0, 0.0)pass_rate = candidate_wins / max(1, total_cases)lower_ci = wilson_lower_bound(candidate_wins, total_cases)if lower_ci + 0.015 < baseline_lower_ci:return GateVerdict(False, "Lower 95% CI below baseline regression floor", pass_rate, lower_ci)return GateVerdict(True, "Cleared CI release gate cleanly", pass_rate, lower_ci)
Decisions
| Decision | Required evidence | Review trigger |
|---|---|---|
Enforce 4-layer eval gates (schema/security -> retrieval recall -> pairwise AB/BA judge -> human spot-check). | Hard 0-tolerance fail on safety/security slice regressions | Model version, system prompt, or retriever swap |
Calibrate automated LLM judges monthly via swapped order (AB/BA) against labeled human preferences. | Cohen's kappa >= 0.75 and position bias < 3% | Judge prompt updates or new domain tasks |
Alternatives and trade-offs
- LLM-as-a-Judge + Deterministic Unit Gates vs. Pure Human Review: Automated judges scale CI gating across thousands of regression cases in minutes, while reserving expensive human domain experts for borderline pairwise ties and calibration drift audits.
Failure modes
- Aggregate averages hide critical cohort collapses: A
95%pass rate across easy English FAQ prompts masks a0%collapse on high-liability multi-turn tool refusals. - Unverified LLM-as-a-judge biases: Judging verbose fluent formatting higher than concise exactness or systematically favoring Position A corrupts automated model comparisons.
- Evaluating models in isolation without tools/retrievers: Scoring offline single-turn completions overlooks broken retrieval permissions, truncation bugs, or flaky tool schemas in the full harness.
- Static stale eval sets overfitting prompts: Engineers memorize fixed public benchmarks; continuously stream sampled production failures into rolling private slices while checking judge calibration monthly.
Operational checklist
- Golden evaluation packs pair representative normal traffic with hard adversarial & long-tail cohorts.
- Critical safety/security regressions block promotion deterministically (
0tolerance, never averaged away). - Pairwise LLM judges undergo position swapping (
AB / BA) and monthly Cohen's human calibration. - Every release artifact (
model_sha,prompt_sha,retriever_epoch) logs paired baseline comparison receipts. - Production telemetry drift (
OTel gen_ai.*metrics) automatically reopens CI evaluation baselines.
Connected Practice
- Labs: /labs/evaluation-strategy-designer, /labs/evaluation-metric-comparison
- Projects: /projects/evaluation-control-system-project
- System breakdowns: /systems/inside-langgraph
Sources
- Evaluation control plane references:
openai-evals,anthropic-agent-evals,nist-ai-rmf,otel-genai
Debug live agent loops & tool-call failure recovery
Inject schema mismatches, 429 rate limits, and timeout circuit breakers inside the ReAct Agent Loop Debugger — or query this knowledge inside Cursor/Claude via MCP.
Subscribe to Engineering Briefings
Join AI systems engineers receiving architecture teardowns, benchmark notes, and new simulator releases. Unsubscribe anytime.
