Page 5 of 8~112 min topic

Eval metrics lab

Handle failures and retries

When eval set leaked into few-shot examples — scores look perfect, prod drops, the system must degrade on purpose without widening blast radius.

~14 min this pageFailure handling

1Learn the idea

Read

Classify and bound retries

Map failure classes for python -m eval.run --gold v12: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to release needs groundedness ≥ 0.88 and latency p95 ≤ 2.0s on fixed gold set v12. The chapter’s signature failure — eval set leaked into few-shot examples — scores look perfect, prod drops — must take a deliberate branch, not a generic catch-all.

Read

Containment path

Implement the degrade/rollback/refuse behavior ML engineer gating a prompt change before Friday release needs when EVAL-LEAK-308 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”

Read

Implementation artifact

if report.groundedness < GATES["groundedness"]:
    sys.exit("gate_fail:groundedness")

Read

Verify harm reduction

After containment, check groundedness, citation_precision, p95_latency_ms moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.

Read

Stage depth

Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how eval set leaked into few-shot examples — scores look perfect, prod drops becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for groundedness, citation_precision, p95_latency_ms.

Read

Field notes for `eval-metrics-lab` / `failure-handling`

Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. In this chapter the product is offline+online eval harness for grounded support answers, the human stakeholder is ML engineer gating a prompt change before Friday release, and the incident id you design against is EVAL-LEAK-308. Re-state the oracle in your notes — candidate prompt beats baseline on groundedness by ≥ 0.03 without latency regression > 10% — and keep the invariant visible: release needs groundedness ≥ 0.88 and latency p95 ≤ 2.0s on fixed gold set v12. Track groundedness, citation_precision, p95_latency_ms as the scoreboard. Surface under change control: python -m eval.run --gold v12. If you only have forty minutes, finish the fixture for eval set leaked into few-shot examples — scores look perfect, prod drops before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Go deeper

Before you start

Why this matters

Assume eval set leaked into few-shot examples — scores look perfect, prod drops is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: release needs groundedness ≥ 0.88 and latency p95 ≤ 2.0s on fixed gold set v12.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Are retry budgets explicit?
2. Is containment scoped?
3. Do you preserve evidence for EVAL-LEAK-308?

All responses are required.