
AI agents change constantly: a prompt tweak, a model upgrade, or a new tool definition shifts behavior in ways that static checks cannot see. Classic one-off test runs assume a frozen configuration, which stops working the moment an agent is live and evolving. The alternative is a continuous evaluation loop in which masked production traces become the raw material for regression cases, automated judges score every release, and online evaluation watches live traffic. The loop has five recurring steps: generate eval cases from masked production traces, provision the test data, run and score, observe live behavior, and feed failures back to development. Each step has concrete implementation decisions around masking, dataset design, judge calibration, and CI gating. The article is aimed at engineers building a continuous evaluation pipeline rather than running occasional ad-hoc tests.

AI agents evolve through prompt edits, model swaps, and tool‑schema changes that static type‑checkers or one‑off test suites cannot capture. A practical way to keep pace is to treat evaluation as a continuous data pipeline rather than a single pre‑release experiment.
Generate eval cases from masked production data – By extracting real interactions, stripping personally identifiable information, and preserving the full context (prompt, tool calls, retrieval results), teams build realistic regression scenarios that reflect actual usage patterns K2view.
Provision the exact context each case needs – The pipeline stores the masked trace together with any auxiliary assets (knowledge‑base snapshots, tool configurations) so the case can be replayed verbatim during testing. This reproducibility eliminates “it works on my machine” gaps and ensures that scoring criteria see the same inputs that occurred in production K2view.
Run and score – Evaluation can rely on a deterministic rule set or an LLM‑as‑a‑judge that compares the agent’s answer to a reference or rubric. Using a single scoring rubric for both offline experiments and online monitoring guarantees that quality signals are comparable across environments K2view.
Observe live behavior – While the agent handles live traffic, the same scoring logic is applied in‑line, and each interaction is captured as a full trace (spans for LLM calls, tool invocations, retrievers). Continuous online scoring surfaces regressions the moment they appear, turning production into an ongoing test harness K2view; LangChain.
Feed failure traces back to developers – When a live score falls below threshold, the complete trace is routed to the development team for rapid root‑cause analysis and for turning the failure into a new regression case. This closed feedback loop shortens the mean‑time‑to‑repair and enriches the dataset over time K2view.
The loop distinguishes offline evaluation (the safety net of curated datasets and controlled experiments) from online evaluation (continuous scoring of production traffic). A mature practice runs both in parallel: offline checks catch known failure modes before release, while online checks detect drift caused by unseen prompt variations or model updates.
Crucially, the loop assumes the agent is instrumented to emit a structured trace for every request, typically as a span hierarchy covering LLM calls, tool usage, and retrieval steps. This trace is the raw material consumed by all subsequent stages.
K2view presents the five‑step sequence as a best‑practice template rather than a formal standard; organizations often adopt it as a recurring cadence (e.g., weekly regression runs) and adapt the steps to their tooling and governance needs.

Trace‑to‑test workflow
Four fields to record per trace (aligned with Label Studio guidance)
Masking layer
Before a trace is added to the dataset, a sanitization step removes or substitutes any sensitive information【0†url】:
If masking cannot sufficiently protect the data, the trace should be rewritten as a synthetic equivalent that mirrors the failure pattern without exposing the original content【0†url】.
Sampling recommendation
Rather than amassing hundreds of random traces, teams typically curate a modest, balanced set—on the order of a few dozen examples—mixing representative successes with clear failures. A common starting point is roughly twenty successful traces and ten failing traces, which provides enough signal to calibrate judges while keeping the dataset manageable. This deliberate selection yields higher diagnostic value than sheer volume.

The test dataset should mirror the distribution of live inputs rather than simply amass a large volume of examples. Effective coverage is achieved by stratifying cases across the dimensions that most affect agent behavior:
By reflecting the production‑trace distribution, the golden set increases the likelihood that regressions discovered in CI will also surface in the field.
| Target | Approx. # examples | What it can reveal |
|---|---|---|
| Minimal “quick‑check” set | 20 – 50 (community suggestions) | Catches obvious, high‑impact regressions; useful for smoke‑suite runs. |
| Large‑regression detector | ~50 | Sufficient to spot major drops in performance. |
| Statistical confidence for 3‑5 % quality changes | ~200 | Enables detection of modest quality shifts with reasonable confidence Galtea. |
| Highly varied sub‑tasks | >500 | Only worthwhile when the agent handles many distinct domains; otherwise diminishing returns. |
Empirical analysis of binary pass/fail scores shows that a 200‑question set yields a 95 % confidence interval of roughly ±5 pts around an 80 % pass rate, making a 5‑point regression statistically observable BERI.
The preferred design approach is bottom‑up failure analysis: start by collecting real failures from production, then augment with targeted edge cases, rather than beginning with a top‑down metric checklist. This yields a dataset that predicts actual production issues more reliably Galtea.
Each entry should be a self‑contained record containing:
input – the raw prompt or user utterance.reference – the expected answer, answer sketch, or evaluation target.metadata – a structured object with fields such as category (e.g., “search”, “transaction”), difficulty (e.g., “easy”, “hard”), language, and source (e.g., “production”, “synthetic”).Storing this information in a version‑controlled data file (e.g., JSONL) alongside the prompt templates it evaluates allows reproducible CI runs and straightforward diffing when the dataset evolves.
The golden set is a living artifact:
Version‑controlling both tiers enables teams to trace performance changes back to specific dataset updates, supporting disciplined, data‑driven iteration on AI agents.

An LLM‑as‑a‑Judge is a secondary, instruction‑following model that receives three inputs: the candidate answer, the evidence that produced it (retrieved documents, tool calls, original prompt), and a rubric describing the quality criteria. The judge returns a categorical label, a numeric score, an explanatory comment, or a structured JSON object that can be parsed automatically — for example the Arize format 【1】.
| Metric | Definition | Typical rubric logic |
|---|---|---|
| Groundedness / Faithfulness | The answer must only assert claims found in the retrieved context. A failure indicates the model invented facts that are unsupported by the evidence 【4】. | “All factual statements are supported by at least one retrieved passage; otherwise score 0.” |
| Answer Relevancy | Measures how well the response matches the user’s intent. Even a perfectly factual answer can be penalised if it diverges from the question. | “The core purpose of the user query is addressed; relevance score ≥ 0.7 passes.” |
| Hallucination Rate | Frequency of statements that cannot be traced back to any provided context. This is computed by asking the judge to locate each claim in the evidence; missing links count as hallucinations 【4】. | “Count of unsupported claims ÷ total claims; flag if > 0.15.” |
Running a full LLM judge is the most expensive primitive. Best practice is to place it last in a cascade after cheaper deterministic checks (schema validation, exact‑match, rule‑based classifiers). Only the subset of traces that survive earlier gates are sent to the judge, dramatically reducing inference cost while preserving semantic coverage 【2】.
Many teams adopt managed evaluator catalogs such as Ragas, which provide ready‑made judges for hallucination detection, context relevance, and helpfulness 【3】. These services expose the same primitive (model + rubric) but offload prompt engineering, scaling, and monitoring to the provider, allowing teams to focus on integration.
Judges themselves can regress. A robust pipeline therefore includes a regression suite for the judge, consisting of version‑sensitive test cases tied to authoritative documentation (e.g., platform API specs). When a new judge version is deployed, the suite validates that expected scores on these anchor cases remain stable, alerting engineers to inadvertent drift 【1】.
By combining precise rubric design, context‑aware judging, structured outputs, and a cost‑effective cascade, engineers can turn masked production traces into reliable, continuously scored evaluation datasets that keep AI agents aligned with their intended behavior.

Automated judge scores become reliable release signals only after they are calibrated to human judgment. A documented calibration loop (Galatea) follows these steps:
An alternative formulation used by Braintrust expands the human sample to 100–200 items and measures agreement with Cohen’s Kappa or Pearson correlation【https://www.braintrust.dev/articles/what-is-prompt-evaluation】.
When calibrated on suitable data, strong judges achieve 80–90 % agreement with human reviewers on many criteria, a level comparable to the inter‑annotator agreement typically observed between two humans【https://langfuse.com/blog/2025-11-12-evals】. This ceiling should be reported as an empirical observation, not a guaranteed performance bound.
| Bias | Typical magnitude | Typical mitigation |
|---|---|---|
| Position bias – preference for the first (or second) option in pairwise comparisons | 5–15 % shift in scores when order is swapped【https://arxiv.org/html/2601.22025v1】 | Randomize option order; run each pair twice with swapped order and treat flips as ties |
| Verbosity bias – longer outputs receive higher scores irrespective of content | 10–20 % | Length‑normalize or penalize unnecessary tokens |
| Self‑preference bias – judges favor outputs from the same model family | 10–25 % | Use a judge from a different model family than the evaluated agent |
| Style bias – preference for confident or “authoritative” tone | Variable | Include style‑neutral rubric items; blind the judge to stylistic cues |
| Rubric‑instruction leakage – judges exploit subtle hints in the rubric to inflate scores | Variable | Ensure rubric language does not hint at the correct answer; keep prompts concise |
By systematically calibrating judges against human labels, measuring agreement with robust statistics, and applying bias‑aware mitigations, the evaluation loop can yield trustworthy signals for gating releases and driving continuous improvement.

Online evaluators work on the raw trace that is captured the moment a request enters the system. Rather than replaying the entire LLM call stack, the evaluator reads the already‑recorded inputs, tool‑call metadata, and final output, and scores the observation within seconds of ingestion 【1†L1-L7】. Because the evaluation runs asynchronously, it adds only a small latency and can be applied to every trace or to a strategically sampled subset.
Online evaluators can also flag transient problems that never appear in the final answer:
Scoring every trace can be expensive. A common practice is to sample a modest fraction—e.g., 5 % of matching observations—so that judge‑inference spend stays proportional to the team’s monitoring budget. This rate is stored as a configurable default rather than a universal standard 【1†L8-L12】. Deterministic sampling (identical filters and rate for all evaluators) guarantees that different judges score the same subset, making their metrics directly comparable 【1†L13-L15】.
Because scores are attached to the original span, a newly added evaluator can be run retroactively over historical traces, creating a pre‑launch baseline and enabling trend analysis across version changes 【4†L1-L7】.
Aggregated scores are plotted on dashboards (average score over time, distribution histograms, version‑wise breakdown). Alert rules trigger when metrics dip below defined thresholds, pushing notifications to Slack, PagerDuty, or email 【5†L1-L10】. This closed‑loop visibility ensures that regressions are caught in real time and routed back to development for rapid remediation.

“The loop turns production bugs into proactive test cases” — Braintrust [2].
For multi‑step traces, a structured review UI (e.g., Label Studio [5]) guides domain experts through each interaction:
| Step | Rating | Rubric dimensions |
|---|---|---|
| 1 – Retrieval | Correct / Partial / Incorrect | Completeness, Safety, Efficiency |
| 2 – Tool use | … | … |
| 3 – Final answer | … | … |
This systematic annotation turns ad‑hoc observations into machine‑readable signals that can train or calibrate judges.
| Cadence | When to trigger |
|---|---|
| Event‑driven | Immediately after a monitoring alert or user‑reported incident. |
| Scheduled | Nightly or weekly batch runs that sweep recent failures into the suite. |
| Release‑gate | Before every CI/CD promotion; the suite acts as a gate that must remain green. |
Choosing a cadence depends on risk tolerance and release velocity; many teams combine event‑driven ingestion for critical bugs with a nightly bulk update for lower‑severity issues.
A trace captures what happened in a single live execution, while an evaluation asks whether a change works across many inputs. By converting each failing trace into a regression case, the offline test suite continuously mirrors the production environment. The growing suite therefore tests the agent not only against synthetic benchmarks but also against the exact scenarios that previously broke it, preserving a feedback loop that remains honest and grounded in reality.

Using the same scoring criteria for both pre‑deployment evaluation and in‑production monitoring guarantees that any observed change in a metric reflects a real shift in model behavior, not a measurement artifact. When the rubric, judge model, temperature, or threshold definitions differ between contexts, a drop in score could simply be the result of a new measurement method, making regressions indistinguishable — a problem highlighted in the K2view observability guide: “Using identical criteria ensures that the pre‑deployment evaluation score is directly comparable to the in‑production score”【1†url】.
Each evaluation result records the rubric version that produced it. When a rubric is updated, historical scores are flagged as non‑comparable, and a new baseline is established. Pinning both the dataset version and rubric version in CI guarantees that re‑runs are deterministic.
By enforcing identical scoring criteria, the five‑step evaluation loop maintains a single, continuous quality signal. Engineers can confidently attribute any metric deviation to genuine model regression rather than to a change in measurement, enabling rapid, reliable gating of releases and consistent observability throughout an agent’s lifecycle.