Learn › Testing & Evaluating AI Agents and RAG › The Eval Loop: From Production to CI

The Eval Loop: From Production to CI

Intermediate 🕐 16 min Lesson 10 of 11
What you'll learn
  • Describe the offline and online evaluation loop
  • Convert production failures into regression tests
  • Set thresholds that gate changes in CI
  • Plan a fast suite, a full suite, and online monitors
  • Track cost and latency alongside quality

A Loop, Not a Checkpoint

LangSmith's documentation describes the pattern clearly. Offline evaluation runs on a dataset before deployment, and is used for benchmarking, regression testing, and unit-style checks. Online evaluation scores real production runs, which have no reference answers, and is used for monitoring and anomaly detection. The two feed each other: online evaluation surfaces issues that become offline test cases, offline evaluation validates the fix, and online evaluation confirms the improvement in production.

Turn Failures Into Tests

Every production failure is a free test case. Runs with negative user feedback, errors, or unusually high latency can be converted into dataset examples. A simple routine:

  1. Collect flagged runs each week
  2. Read them and label the cause using your failure taxonomy
  3. Write the correct expected behavior and redact private data
  4. Add them to the golden set with a note about their source
  5. Confirm the current system fails them, then fix it and confirm they pass

Over time your suite becomes a record of everything that has ever gone wrong, which is exactly what a regression suite should be.

Evaluation Versus Testing in Practice

LangSmith's docs note that evaluation metrics can be turned into regression tests by setting a threshold, and that evals can run inside ordinary test frameworks such as pytest. Because outputs vary, use thresholds and multiple trials, not exact equality. Decide in advance what size of drop counts as a regression, since small random wobbles are normal. If your suite has 30 tasks, one task flipping is a 3-point swing and may be noise; look at several runs before reacting.

Gate Every Change

Run the suite whenever you change a prompt, a tool, a retrieval setting, or the model. In continuous integration, make the suite exit with a non-zero code if the pass rate drops below your threshold, so the change cannot merge. Anthropic's guide recommends eval-driven development, and OpenAI says to evaluate early and often. A practical split:

  • Fast suite — 20 to 50 tasks, code graders, runs on every change
  • Full suite — larger set with model graders and more trials, runs nightly or before release
  • Online monitors — reference-free checks on live traffic with alerts

Model Upgrades Are Changes Too

A new model version can change behavior in ways your prompts did not anticipate, in either direction. Run the full suite before switching, compare per-category results, and read the transcripts of tasks that got worse. A newer model that is better on average can still regress on one category you care about.

Budget Cost and Latency

Quality is one dimension. Anthropic's example evals also track turns, tool calls, tokens, and latency. Add them to your suite output and set budgets, so a prompt that gains two points of accuracy by doubling cost shows up as a trade-off instead of a surprise. Remember that running several trials per task multiplies API cost, and model-based graders add their own calls, so keep the fast suite small and run the expensive checks less often.

Keep the Suite Healthy

  • Watch for saturation: a suite at 100% cannot show improvement, so add harder tasks
  • Give the suite an owner, and let domain and product experts contribute tasks
  • Read transcripts regularly, not only the scores
  • Retire tasks that no longer reflect real use, and re-check graders when a task keeps failing

Try This

Write down your loop on one page: where failures are captured, who adds them to the dataset, which suite runs on each change, what threshold blocks a merge, what you check weekly in production, and what cost and latency budgets apply. If any box is empty, that is your next task.

Key takeaways
  • Production failures are your best new test cases
  • Use thresholds and multiple trials because outputs vary
  • Run a fast suite on every change and a full suite before release
  • Treat model upgrades as changes that need a full eval
  • Retire saturated tasks and add harder ones
Learn more every week Get 5 hand-picked prompts + new AI tools every Monday. Free.