Skip to content
mentoor

Topic 3 of 5 · 5 min read

Turning failures into regression eval cases

Goal: Turn a failing production trace into an anonymised eval case with a grader.

A production failure becomes a regression case when you strip the personal data, state what a correct answer must do, attach a check that can fail, and add it to a set that still reflects normal traffic. The case should keep failing until the fix, then guard against the failure coming back.

Check yourself · 1 of 3

A new regression case passes on the current, unfixed version. What does that tell you?

Choose one answer

Why it matters

Fixing a bug in a prompt without a case is a guess that will be undone by the next edit. A case turns one bad trace into a permanent test. The risk on the other side is a set made only of last week's bugs, which makes every new version look worse at ordinary work.

How to do it

  1. Rebuild the input. Take the user message, the retrieved context and tool results from the trace id.
  2. Remove personal data. Replace names, emails, phone numbers, order numbers and account details with realistic fake values. Keep the structure that caused the failure, such as a date format or a long thread.
  3. Write the expected behaviour as a rule, not as one exact reply. Models word things differently each run.
  4. Choose a grader. Use code when a check is exact (the answer contains the refund window found in the context, the tool call includes an order id). Use a model judge only for properties code cannot test, and check the judge against your own labels.
  5. Confirm it fails today. Run it on the current version. A case that passes before the fix tests nothing.
  6. Tag it with the failure category and the source trace.

Before and after

Weak: save the raw trace and the bad answer as the "golden" reply.

Better:

id: refund-window-ungrounded-014
category: ungrounded-answer
source_trace: tr_8f21
input:
  user: "Can I return the blender I bought on 3 March?"
  context: "Returns are accepted within 30 days of delivery."
expect:
  - answer_states: "30 days"
  - answer_must_not_state: "60 days"
grader: code

Keep the set balanced

Hold a share of cases from normal traffic and from older categories. When a category has many cases, sample from it instead of adding all. Keep a held-out slice you never tune against.

What goes wrong

  • Real data left in. An email address in a case file is a privacy incident.
  • Exact-match expectations. The case fails on harmless rewording.
  • Overfitting. The prompt learns the cases and gets worse on everything else.

Examples

A tool-call case

A trace shows the bot calling issue_refund without an order id. The case input uses a fake order thread. The grader is code: it parses the tool call and fails if order_id is empty. It fails today, passes after the fix and runs on every prompt change.

Too many of one kind

After a refund incident the set has 40 refund cases out of 120. The team keeps 12 of them, picks the most different ones, and adds the rest to a separate suite that runs only on refund changes.

Key points

  • Rebuild the case from the trace id, then replace personal data with realistic fake values that keep the failing structure.
  • Write the expected behaviour as a rule a grader can check, not as one exact reply.
  • Prefer a code grader when the check is exact, and validate any model judge against your own labels.
  • Run the new case on the current version and confirm it fails before you start the fix.
  • Keep a balanced set with normal traffic and a held-out slice so you do not overfit last week's bugs.

Common mistakes

  • Pasting raw production text, with real names and emails, into the eval file.
  • Saving the model's bad answer as the golden answer.
  • Skipping the check that the new case fails on the current version.
  • Letting one recent incident dominate the set.

Check yourself · 2 of 3

Which expected result makes the best regression case for an ungrounded answer about a return window?

Choose one answer

Check yourself · 3 of 3

Why not add every failure from last week to the eval set?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic