Course map · Module 4 of 6

Verification, Evaluation and Improvement

Central question: How does the system know whether it is becoming better?

The trust module. Fresh-context critics with teeth, repair loops with brakes, datasets that can fail, and optimization that never ships a regression — capped by the gate that lets agents merge without you.

Tool labs · DSPy, LangSmith, Pydantic Evals   Expert lenses · Omar Khattab, Matei Zaharia
LESSON 4.1

Read-only critics and verification gates

Core idea

Models grade their own work kindly: measured self-preference bias runs 10–25%, and a model recognizes its own writing most of the time. So the maker never grades its own exam. A verifier is a separate node with fresh context — ideally a different model — whose only job is to try to kill the result before it moves downstream. Critics read; they never fix. The gate either passes evidence or blocks with a reason.

Expert lens

The NeurIPS self-preference findings made this quantitative; every serious 2026 practitioner curriculum converged on fresh-context verification as table stakes.

Tool lens

In any framework this is one node with two properties: no shared conversation history with the maker, and a verdict schema (pass/fail + evidence) instead of free text.

Build

Add a fresh-context critic to your Module 2 research graph. Prompt it to refute, not to review.

Verify

Feed it one output with a planted factual error. The gate must block it and name the error. Feed the clean version; it must pass. Both traces saved.

Connect

Adds fresh-context-verify — the single highest-leverage reliability pattern in the course.

LESSON 4.2

Evidence beats self-report: bounded repair

Core idea

Never accept 'done' as a claim — define done as a verifiable state of the world: tests pass, the file exists, the URL resolves, the number reconciles. When verification fails, repair with a budget: two or three attempts, each required to change approach, then stop and escalate with a report of what was tried. Unbounded self-repair is how agents dig confident holes.

Expert lens

The software-factory pattern: exams written before code exists, a night-shift executor that takes them, circuit breakers that stop it from digging, and a fresh reviewer that reruns everything.

Tool lens

LangSmith traces show you every repair attempt with its diff; a repair loop without observability is indistinguishable from a hang.

Build

Wrap one flaky node in a bounded repair cycle: 3 attempts max, each must state its changed approach, then escalate.

Verify

Two test runs: one that recovers on attempt 2 (trace shows two distinct approaches) and one that exhausts the budget and escalates cleanly with a summary.

Connect

Adds bounded-repair; pairs permanently with 4.1's gate.

LESSON 4.3

Datasets, metrics, and two-level evaluation

Core idea

You cannot improve what you measure vaguely. Build the dataset first: 20–50 real input/expected-output pairs including the ugly edge cases. Then evaluate at two levels — node-level (is the extractor right?) and graph-level (is the shipped answer right?) — because a graph of individually-fine nodes can still compose a wrong answer, and expected-vs-actual trajectory comparison tells you which edge betrayed you.

Expert lens

Matei Zaharia's systems lens: evaluation infrastructure is what turns AI programs from demos into engineering; DSPy exists because metrics make optimization possible.

Tool lens

LangSmith runs dataset evaluations and compares graph versions side-by-side; Pydantic Evals types your cases and scores; both diff trajectories, not just outputs.

Build

Build a 25-case dataset for your Module 2 graph — at least five cases must be adversarial (ambiguous, contradictory, or trap inputs). Define one metric per node plus one end-to-end metric.

Verify

Run the baseline. Every metric must produce a number. If any metric can't fail, redesign it — a metric that always passes measures nothing.

Connect

Adds two-level-eval; 4.4 points an optimizer at it.

LESSON 4.4

Automated optimization without regression

Core idea

Once a node has a metric, its prompt becomes a parameter you can optimize instead of hand-tune. DSPy treats the program as a computational graph and searches instructions and demonstrations against your metric. The discipline that keeps it honest: optimize one node while the rest of the graph's metrics run as a regression suite — a better extractor that breaks the summarizer is a net loss. Then read the cost column: a 2% accuracy gain at 3× tokens is usually the wrong trade.

Expert lens

Omar Khattab's core argument: program, don't prompt — declare what each stage should do and let the optimizer find the words. Zaharia: measure the whole system, not the part.

Tool lens

DSPy optimizers (instruction search, demonstration selection) against your 4.3 metric; LangSmith regression comparison across graph versions.

Build

Optimize your weakest node with DSPy against its metric, holding the dataset's test split out.

Verify

Report four numbers: node metric before/after, graph metric before/after. Ship only if both improved or the graph metric held while cost dropped. Write the one-paragraph trade-off memo.

Connect

Completes the improvement cluster: your graph now has a feedback loop that doesn't require you.

LESSON 4.5

The judge is part of the system under test

Core idea

LLM judges respond to things other than the content in front of them. Frontier judges systematically inflate their own model family — one 2026 benchmark measured 75–84% self-family win rates for GPT-5.2 and Gemini 3.1 Pro (Claude Opus 4.7 went the other way, under-rating its own family), with cross-judge bias on ArenaHard spanning −38% to +90%; the same outputs scored 93.3% under one judge and 39.5% under another. Verbosity bias runs alongside. Three rules absorb most of it: judge from a different family than the generator; panel across vendors for anything high-stakes (averaging across families breaks correlated errors); anything objectively checkable goes to code, not a judge. Then treat the judge as software: pin its version and log it with every score, write rubrics as “pass if the observable outcome happened,” and never reward shape — length, keywords, citation count — or you hand the agent a Goodhart target and your defense becomes an attack surface.

Expert lens

Hanako (@hanakoxbt)’s eval-engineering course: “A gate fed by a biased judge is worse than no gate. It launders a guess into a number and then acts on it.” And DeepMind’s ICLR 2024 result stands behind the external-grounding rule: intrinsic self-correction — a model reviewing its own work with no outside signal — does not reliably help and often hurts.

Tool lens

LangSmith records which judge model and version produced every score; Pydantic Evals encodes pass-if rubrics as code. This module’s read-only critics now get families: the critic that grades a node should never share a lineage with the node it grades.

Build

Run your Module 4 critic suite twice with judges from two different families and diff the verdicts. Move every objectively checkable criterion (test passed, file exists, schema valid) out of the judge and into code.

Verify

Test the verifier before trusting it: feed it one clearly correct result and one plausible wrong one — if either goes the wrong way, the rubric is broken, not the agent. Size the suite to survive contact: enough cases to trust the aggregate, short enough that nobody plans around the run.

Connect

Adds cross-family-panel and pin-the-judge. Source: @hanakoxbt’s Eval Engineering.

LESSON 4.6

Verdicts that steer, evals from traces, and the blast-radius gate

Core idea

A verdict that does not change the run is a report — a thermometer, not a thermostat. Mature systems map each verdict to a structural action on the run in progress: low grounding rejects the handoff, a schema failure blocks the edge, a suspected fabrication quarantines the branch, and only verified completion may end the run (an agent that stops calling tools has ended its turn, not the task). Grade the path, not just the answer — end-to-end, trajectory, and component levels, with faithfulness, tool-parameter accuracy, and task completion as the starting metrics; an identical diff that arrived after forty steps of thrashing is a different risk from one that arrived clean. Your best test cases are already in your logs: a clean run, a user-corrected run (the correction is a free label), an empty tool return, an external timeout. And the gate that finally lets agents merge without you opens on blast radius, not confidence: reversible-and-contained work opens first; reversible-but-wide needs deterministic checks plus a clean trajectory; hard-to-reverse — migrations, deletions, money — does not open, regardless of score. Inside a lane, evidence order matters: deterministic results first, trajectory second, rollback history third, and the model’s self-assessment weighted least, because it is the one input the model can influence.

Expert lens

Hanako (@hanakoxbt): the end state is not trust in the agent — “it is a constraint tight enough that trust stops being the question.” Run the gate in shadow first, merging nothing, and keep it closed while gate-versus-human disagreement is meaningfully above zero. Green is evidence, not proof.

Tool lens

LangSmith’s trajectory-level evals grade the path; promoted into runtime guardrails they become the verdict→action wiring. Module 2’s human-approval gate becomes lane-conditional: the human leaves the reversible lane first and the irreversible lane never.

Build

Sort your last twenty changes into the three lanes. Wire one verdict→action into a real graph (reject the handoff on low grounding). Mine five evals from traces using the four-line write-up: what happened, what worked, whose fault, which capability to protect.

Verify

Shadow the gate for a week and log every gate-versus-human disagreement with a reason. The hard-to-reverse lane’s merge count must be exactly zero. Every mined failure must exist as a permanent test — any failure you don’t convert, you will meet again.

Connect

Adds verdict-steering, trace-mined-evals, blast-radius-lanes. The model on your card statement is a rental; the examiner around it is the part you keep. Source: @hanakoxbt.

Unlock the rest of Module 4

Lesson 1 of every module is open. The full module — all lessons, the tool lab, and the graded project — unlocks with any plan.

Try Free — 30 Days (no card) Own the course — $6.93 Compare plans

Purchased already? Sign in with your checkout email.

Tool lab

DSPy + LangSmith + Pydantic Evals

One pipeline, three instruments: Pydantic Evals types the dataset, LangSmith traces and compares versions, DSPy optimizes the weakest node against the metric. You leave with an evaluation harness you can point at any graph you ever build.

Module project · graded by evidence

Evaluation suite + one optimized node

Create the full evaluation suite for your Module 2 research graph, then measurably improve one node without degrading the rest.

Acceptance criteria — all must be demonstrably true:

  • 25+ case dataset with adversarial cases and a held-out test split
  • Node-level and graph-level metrics that can demonstrably fail
  • One node optimized: before/after numbers at both levels
  • A cost line: tokens per run before and after, with the trade-off called