The most common finding in our production readiness audits is not a bad prompt, a wrong model or a broken retrieval pipeline. It is a system with no automated evaluation at all. The release process is someone pasting their three favourite prompts into staging, reading the answers and shipping.
That is usually a rational trade made under demo pressure, not incompetence. But once the system is live, every prompt tweak, model upgrade and provider deprecation becomes a gamble, and your customers are the test suite. Agents make it worse: a small regression in step two shows up as a wrong action in step seven.
This is the retrofit path we use on audit engagements. It takes a live system with no evals to a suite that gates deploys and watches production, without pausing the roadmap. The first useful checks run on day one. The whole thing takes about two weeks of one engineer's part-time attention plus a few hours from a domain expert.
Why systems ship without evals
The usual excuse is nondeterminism: you can't unit-test a model that answers differently every time. It is half true, and the false half matters more. Most of what an LLM system does is not free-form prose. It extracts fields, routes tickets, calls tools and cites documents, and those things have right answers.
The real blocker is the cold start. Faced with an empty evals/ folder, nobody knows what to assert. The way out is to stop trying to invent a test set and start mining one from production.
Step zero: mine production traces for a golden set
A system that has been live for a few months has already produced a better test set than any workshop could. Pull 50 to 100 real requests from your traces. For agents, Anthropic's guidance is that 20 to 50 tasks drawn from real failures is enough to start.1 The mix we aim for:
- About 60% routine traffic. The requests the system handles all day. These become the regression floor.
- About 20% known-hard cases. Long documents, ambiguous questions, unexpected formats, other languages.
- About 20% real failures. Every answer a customer or support agent flagged as wrong is a test case with the label already attached.
Include cases where the system should not act: questions it should decline, requests where the right move is to ask a clarifying question. A suite with only positive cases trains the team to build an agent that does too much.1
For each case, capture the full record, not just the input: the retrieved documents, tool calls and results, final output, model and prompt version, latency and token counts. Scrub PII before any of it reaches the eval repo. If you can't do this because nothing was logged, that is the first finding. Fix tracing before anything else. An eval suite built on invented examples tests the system you imagine, not the one you run.
Build a failure taxonomy before you write checks
The step most teams skip is reading. Sit down with one engineer and one domain expert and go through 50 to 100 traces. Write a short free-text note on everything that is wrong with each one, then group the notes into categories and count them. Don't start from a generic list of metrics. Research on LLM-assisted evaluation found that people only work out their criteria by grading real outputs, and the criteria keep shifting as they see more.2
A typical taxonomy for a RAG support assistant looks like this:
| Failure category | Example | Best check |
|---|---|---|
| Retrieval miss | The policy that answers the question was never retrieved | Code: expected doc ID in top-k |
| Ungrounded claim | Answer states a fee the sources don't mention | Calibrated judge or faithfulness metric |
| Wrong tool or arguments | Looked up the wrong order ID | Code: trajectory invariants |
| Format violation | Missing citation field, invalid JSON | Code: schema validation |
| Should have abstained | Guessed when the data wasn't there | Code on labeled cases; judge on open ones |
| Tone or policy | Promised a refund the policy doesn't allow | Calibrated judge |
| Cost or latency | Agent looped for 14 steps | Code: budgets on the trace |
The counts tell you where to start. They also tell you which failures are cheap to check and which need a judge. On most systems we audit, a surprising share of the categories can be checked with plain code.
Progression
The eval retrofit ladder
Hard assertions first, replayed real traffic second, an LLM judge last — and only after it agrees with your human labels.
Code first, judge second
The rule is simple: anything with a right answer gets a deterministic check, never a judge. That covers schema validity, exact extracted values, numeric ranges, required and forbidden strings, abstention on labeled cases, and cost and latency ceilings. Code-based graders are fast, cheap and reproducible. Model-based graders handle nuance but need calibrating against humans.1
def test_invoice_extraction(case):
result = extract_invoice(case.document)
# Schema first: if this fails, nothing else matters.
InvoiceSchema.model_validate(result)
# Exact fields are exact. No judge required.
assert result.total == case.expected_total
assert result.currency in {"USD", "EUR", "GBP"}
# Missing data must produce abstention, not a guess.
if case.vendor_missing:
assert result.vendor is None
# Cost and latency are product features too.
assert case.trace.total_tokens < 12_000
assert case.trace.latency_ms < 8_000Teams often reach for an LLM judge first because it feels like the AI-native move. Asking a judge whether JSON is valid is slow, expensive and sometimes wrong. A schema validator is free and always right. On most systems we audit, ten checks like these exist by the end of day one, run on every commit in under a minute, and already catch the worst kind of regression: confident, malformed, silently wrong output.
LLM-as-judge, done properly
A judge is the right tool for qualities you can't hard-code: is the answer supported by the sources, is the tone right, does the summary leave out anything important. Used carelessly, it just produces numbers nobody can act on. Four practices make the difference:
- Binary verdicts with a written critique. Nobody can say what separates a 3 from a 4 on a five-point scale. Pass or fail with a reason is easier to calibrate and to act on.3
- One judge per dimension. Grade groundedness and tone with separate prompts, not one prompt that scores everything.1
- An explicit “unknown”. Let the judge say it can't decide, instead of making up a verdict.1
- Calibration against a domain expert. Compare the judge's verdicts with one principal expert's labels. When failures are rare, report true-positive and true-negative rates separately, because raw agreement looks great on a judge that passes everything.3
Here is a groundedness judge in the shape we use:
JUDGE_PROMPT = """You are grading one answer from a customer-support assistant.
Decide ONLY whether the answer is grounded in the SOURCES. Ignore tone and style.
RUBRIC
PASS if every factual claim (amounts, dates, eligibility, steps) is stated
in or directly implied by the SOURCES, or the answer correctly says the
information is not available.
FAIL if any factual claim is missing from the SOURCES, contradicts them,
or adds conditions, numbers or promises they do not contain.
UNKNOWN if the SOURCES are empty or unreadable.
EXAMPLES
{few_shot_examples}
SOURCES
{sources}
QUESTION
{question}
ANSWER
{answer}
Respond with JSON only:
{{"critique": "<one or two sentences naming the specific claim>",
"verdict": "PASS" | "FAIL" | "UNKNOWN"}}"""
def judge_groundedness(case, client, model="judge-model-pinned-version"):
prompt = JUDGE_PROMPT.format(
few_shot_examples=FEW_SHOT, # drawn from the dev split only
sources=case.sources,
question=case.question,
answer=case.answer,
)
raw = client.complete(model=model, prompt=prompt, temperature=0)
return JudgeResult.model_validate_json(raw)
def calibrate(judge_fn, labeled_cases):
"""Compare judge verdicts with expert labels on the held-out test split."""
tp = tn = fp = fn = unknown = 0
for case in labeled_cases:
verdict = judge_fn(case).verdict
if verdict == "UNKNOWN":
unknown += 1
continue
judge_fail, human_fail = verdict == "FAIL", case.label == "FAIL"
tp += judge_fail and human_fail
tn += (not judge_fail) and (not human_fail)
fp += judge_fail and not human_fail
fn += (not judge_fail) and human_fail
return {
"catches_real_failures": tp / max(tp + fn, 1), # TPR on failures
"passes_real_passes": tn / max(tn + fp, 1), # TNR on passes
"unknown_rate": unknown / len(labeled_cases),
}Split the expert-labeled cases into a dev set (where the few-shot examples come from) and a test set you only use to measure the judge.3 Iterate on the rubric until both rates are high enough that you would trust the judge to block a deploy. Then pin the judge model version, and re-calibrate whenever the rubric, the judge model or your traffic changes.
Known judge biases
The original LLM-as-judge research found strong judges agreed with human preferences over 80% of the time. It also documented position bias, verbosity bias and self-enhancement bias.4 Later work showed models can recognise their own outputs and that this correlates with favouring them.5 In practice:
- In pairwise grading, run every comparison twice with the order swapped, and count inconsistent results as ties.
- Use a judge from a different model family than the system under test where you can.
- Write the rubric so length is never a reason to pass, and include short correct answers in your calibration set.
Pairwise or absolute?
| Absolute (pass/fail per output) | Pairwise (A vs B) | |
|---|---|---|
| Best for | Regression gates and production monitoring | Choosing between two prompts or models |
| Strength | Gives a stable number you can set a threshold on | Comparing two outputs is easier than scoring one |
| Weakness | Needs a precise rubric | Position bias; doesn't say whether either is good enough |
We use absolute grading for gates and pairwise for decisions such as “should we move to the new model?”, where comparing two versions is the natural question.6
RAG and agent metrics that mean something
RAG: grade retrieval and generation separately
A wrong RAG answer has two possible causes, and the fix depends on which one it was. Measure them separately:
- Faithfulness (groundedness). The share of claims in the answer that the retrieved context supports. Ragas computes it as supported claims divided by total claims.7
- Context precision and recall. Did retrieval surface the right chunks, and rank them high? Recall needs reference answers or reference documents, which is another reason the labeled golden set comes first.8
- Answer relevance. Does the response actually address the question? An answer can be perfectly grounded and still irrelevant.
A cheap code check often beats all of these for regressions: for each golden case, assert that the document holding the answer appears in the top-k results.
Agents: outcome first, trajectory second
- Task success. Check the end state, not the transcript: was the refund created with the right amount, did the ticket end up in the right queue.
- Trajectory invariants. Assert things that must always or never happen, not an exact sequence. Anthropic warns against rigid tool-sequence checks because agents find valid paths you didn't anticipate.1
- Tool-call correctness. Right tool, valid arguments, no calls outside the allow-list.
- Consistency. pass@k asks whether the agent succeeds at least once in k tries. pass^k asks whether it succeeds every time, which is the one that matters for customer-facing work. A 75% per-trial success rate is only about 42% pass^3.1 The τ-bench authors found that even the strongest function-calling agents they tested solved fewer than half the tasks, with pass^8 below 25% in one domain.9
def test_refund_trace(golden):
trace = replay(golden.request)
# Outcome: the state change is what the customer experiences.
refund = trace.state.refunds.get(golden.order_id)
assert refund is not None and refund.amount == golden.expected_amount
# Invariants, not an exact path.
assert trace.called_before("verify_identity", "issue_refund")
assert "delete_account" not in trace.tools_called
assert len(trace.steps) <= golden.step_budget
# Grounding: the answer must cite the policy it relied on.
assert golden.policy_doc_id in trace.final_answer.citationsA concrete eval config
Here is a small promptfoo config that mixes deterministic and model-graded assertions. The assertion types are taken from promptfoo's documentation. Your application is called through a Python provider, so the suite tests the real pipeline, retrieval included, rather than a bare prompt.101112
# promptfooconfig.yaml (golden set v14)
description: Support assistant regression suite
prompts:
- "{{query}}"
providers:
- id: file://evals/app_provider.py # calls the real RAG pipeline
defaultTest:
options:
provider: openai:gpt-5-mini # grader for model-graded checks; pin it
assert:
- type: is-json
- type: latency
threshold: 8000 # ms
- type: javascript # every answer must carry citations
value: JSON.parse(output).citations.length > 0
tests:
- description: refund window, routine
vars:
query: Can I still return a jacket I bought 20 days ago?
context: file://evals/contexts/returns_policy_v3.txt
assert:
- type: javascript
value: JSON.parse(output).answer.includes("30 days")
- type: context-faithfulness
threshold: 0.9
- type: llm-rubric
value: >-
Answers yes or no first, then the condition. Does not promise
anything the returns policy does not state.
- description: should abstain, no data
vars:
query: What will your prices be next year?
context: file://evals/contexts/empty.txt
assert:
- type: llm-rubric
value: Says it does not have this information and offers a next step.
- type: not-contains
value: "%"Two notes. Assertions in defaultTest apply to every case, so format and latency rules are written once. And because the grader model is set explicitly, an upstream default change can't silently move your scores. The same structure carries over to DeepEval, Inspect or plain pytest.
Evals in CI: gates, thresholds and flakes
A suite nobody is forced to run is just documentation. We wire it into CI in three tiers:
| Tier | When it runs | Gate |
|---|---|---|
| Deterministic checks | Every commit | 100% pass, no overrides |
| Golden traces + judges (smoke subset) | Every PR touching prompts, models, retrieval or tools | Pass rate within the noise band of the baseline |
| Full suite, multiple trials | Nightly and before release | Per-category thresholds; a human reviews any drop |
Flakiness is the main reason suites get switched off, so deal with it from the start:
- Measure the noise band. Run the unchanged baseline five times and record how much the pass rate moves. Set the gate outside that band, not at an arbitrary “no more than 2% drop”.
- Run multiple trials on stochastic cases and gate on pass^k for anything customer-facing.
- Quarantine, don't delete. A case that flips without code changes moves to a quarantine list with an owner and a deadline. Often it is an ambiguous task or a broken grader.1
- Pin everything that can move: model versions, judge version, dataset version, temperature.
- Compare per category, not just overall. A stable average can hide a refund-flow collapse offset by small gains elsewhere.
# ci/eval_gate.py
baseline = load_results("evals/baselines/main.json")
current = load_results("out/results.json")
failures = []
for category, base in baseline.by_category().items():
cur = current.by_category()[category]
if cur.deterministic_failures:
failures.append(f"{category}: deterministic check failed")
if cur.pass_rate < base.pass_rate - base.noise_band:
failures.append(
f"{category}: {cur.pass_rate:.0%} vs baseline "
f"{base.pass_rate:.0%} (band {base.noise_band:.0%})"
)
if failures:
print("\n".join(failures))
raise SystemExit(1)Online evaluation on live traffic
Offline suites catch regressions you predicted. Online evaluation catches the ones you didn't. Production traces have no reference answers, so online evaluators have to be reference-free: groundedness against the retrieved context, format validity, safety, policy compliance.6
- Sample on purpose. A small random sample for an unbiased trend line, plus oversampling of high-signal traces: thumbs-down, user retries, escalations to humans, unusually long agent runs, guardrail triggers.
- Use the calibrated judge, not a new one. An uncalibrated production judge just puts unreliable numbers on a dashboard.
- Alert on trends per category. A one-day dip is noise. A week-long slide in groundedness on one product line is a retrieval problem.
- Close the loop. Failed or ambiguous traces go into an annotation queue, the expert labels them, and confirmed failures become new golden cases. Langfuse and LangSmith both support this workflow out of the box.136
Then keep one manual habit: thirty minutes a week, an engineer and the domain expert, reading ten sampled traces. It is the cheapest eval you will run, and it is where new failure categories show up first.
Operating loop
How the suite keeps up with production
Offline evals gate the deploy. Online evals find what the suite missed, and every confirmed failure becomes a new golden case.
Dataset versioning and drift
Treat the golden set like code. Every case has a stable ID, every version is immutable, and label changes go through review with a reason attached. When a score moves, you need to know whether the system changed or the test did. Store the dataset as JSONL in the repo, or pin the version in your eval platform, so CI always runs against a known set.6
- Keep two suites. A regression suite that should stay near 100%, and a capability suite of hard cases that starts low. Cases graduate from capability to regression as the system improves.1
- Watch for drift. Once a month, compare production traffic with the golden set: topic mix, input length, languages, new tools. If 15% of traffic is now about a product that isn't in the set, the suite is measuring last quarter's system.
- Watch for saturation. A suite that passes 100% for months has stopped telling you anything. Add harder cases.
- Keep test cases out of prompts. Few-shot examples for the judge and the application come from the dev split only.
Tooling in late 2026
The tools are good and mostly interchangeable for the core loop. Choose based on where your traces already live and whether you need to self-host:
| Tool | Shape | Worth knowing |
|---|---|---|
| promptfoo | Open-source CLI, YAML configs, red teaming | Now part of OpenAI; says it remains open source14 |
| DeepEval | Open-source, pytest-style; G-Eval, RAG and agent metrics | Hosted platform is Confident AI15 |
| Ragas | Open-source RAG and agent metrics | Faithfulness, context precision/recall, tool-call accuracy8 |
| Inspect | Open-source eval framework from the UK AI Security Institute | Strong for agent tasks with sandboxed tools16 |
| Langfuse | Open-source tracing, datasets, experiments, LLM-as-judge | Acquired by ClickHouse in January 2026; has a GitHub Action for CI1713 |
| LangSmith | Hosted tracing, datasets, online evaluators, annotation queues | Pairwise evaluation and pinned dataset versions for CI6 |
| Braintrust | Hosted observability, experiments, annotation | Positions itself around agents18 |
| OpenAI Evals platform | Hosted evals in the OpenAI dashboard and API | Deprecated: read-only from 31 Oct 2026, shutting down 30 Nov 202619 |
If you built on the OpenAI Evals platform, migrate now. OpenAI's deprecation notice points to a cookbook guide for moving to promptfoo.19 Whatever you choose, keep the dataset in a portable format you own. Platforms come and go; a labeled golden set is the asset.
What evals cost
The cost formula is simple: cases × trials × (application calls + judge calls) × runs. A 300-case suite with three trials and two judge dimensions makes 900 application runs and 1,800 judge calls per full run. Run that on every PR and it gets expensive. Run it nightly with a 40-case smoke subset on PRs and it usually doesn't.
- Push everything you can into deterministic checks. They cost nothing.
- Once a rubric is tight and calibrated, test whether a smaller judge model holds the same agreement. It often does.
- Cache application outputs when you are only iterating on graders.
- Sample online traffic at a rate tied to volume, not a fixed share.
The biggest cost isn't tokens. It is the domain expert's time, and it is the best money in the whole programme. A few hours of labeling is what makes every automated score trustworthy.
The two-week retrofit
- Days 1–2: pull traces, write the first ten deterministic checks, run them in CI.
- Week 1: error analysis and failure taxonomy, 50–100 labeled cases, trajectory invariants for the top agent flows.
- Week 2: one or two calibrated judges, measured noise bands, deploy gate switched on, online sampling and a weekly trace review on the calendar.
The first blocked bad deploy pays for the effort. The quieter win comes when a provider retires your model. With a suite, migration is an afternoon of running evals against the replacement and reading the diffs. Without one, it is a leap of faith with your customers underneath.
Checklist
- Tracing captures inputs, retrieved context, tool calls, outputs, versions, latency and cost.
- 50–100 production cases labeled pass/fail with a reason, including cases where the system should not act.
- A written failure taxonomy with counts, revisited monthly.
- Deterministic checks for everything with a right answer, gating every commit.
- Agent cases check outcomes and invariants, not exact tool sequences.
- Each judge is binary, single-dimension, has an unknown option, and is calibrated on a held-out expert-labeled split.
- Judge, application model and dataset versions are pinned.
- CI gates on per-category thresholds set outside a measured noise band; flaky cases are quarantined with an owner.
- Online evaluation samples live traffic, oversamples bad signals, and feeds an annotation queue.
- The golden set is versioned, checked for drift and saturation, and grows from production every week.
If you would rather have someone run this retrofit with your team, it is a standard part of our production readiness audit. We leave behind the suite, the labeled set and the CI gate.
Sources
- Anthropic Engineering, “Demystifying evals for AI agents,” 9 Jan 2026 — www.anthropic.com/engineering/demystifying-evals-for-ai-agents
- Shankar et al., “Who Validates the Validators? Aligning LLM-Assisted Evaluation of LLM Outputs with Human Preferences,” arXiv:2404.12272, Apr 2024 — arxiv.org/abs/2404.12272
- Hamel Husain, “Using LLM-as-a-Judge For Evaluation: A Complete Guide” (updated Sep 2026) — hamel.dev/blog/posts/llm-judge/
- Zheng et al., “Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena,” arXiv:2306.05685, 2023 — arxiv.org/abs/2306.05685
- Panickssery, Bowman & Feng, “LLM Evaluators Recognize and Favor Their Own Generations,” arXiv:2404.13076, 2024 — arxiv.org/abs/2404.13076
- LangChain docs, “LangSmith evaluation concepts” — docs.langchain.com/langsmith/evaluation-concepts
- Ragas docs, “Faithfulness” metric — docs.ragas.io/en/stable/concepts/metrics/available_metrics/faithfulness/
- Ragas docs, “List of available metrics” — docs.ragas.io/en/stable/concepts/metrics/available_metrics/
- Yao, Shinn, Razavi & Narasimhan, “τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains,” arXiv:2406.12045, 2024 — arxiv.org/abs/2406.12045
- Promptfoo docs, “Assertions & metrics” — www.promptfoo.dev/docs/configuration/expected-outputs/
- Promptfoo docs, “Context faithfulness” — www.promptfoo.dev/docs/configuration/expected-outputs/model-graded/context-faithfulness/
- Promptfoo docs, “Python provider” — www.promptfoo.dev/docs/providers/python/
- Langfuse docs, “Evaluation overview” — langfuse.com/docs/evaluation/overview
- Promptfoo, “About” — www.promptfoo.dev/about
- Confident AI, DeepEval repository — github.com/confident-ai/deepeval
- UK AI Security Institute, Inspect documentation — inspect.aisi.org.uk/
- ClickHouse, “ClickHouse welcomes Langfuse: The future of open-source LLM observability,” 16 Jan 2026 — clickhouse.com/blog/clickhouse-acquires-langfuse-open-source-llm-observability
- Braintrust documentation — www.braintrust.dev/docs
- OpenAI API docs, “Deprecations” — 2026-06-03: Evals platform — developers.openai.com/api/docs/deprecations
Tool capabilities and status were checked against each project's documentation in October 2026.
