Root & Reason

From production traffic to regression tests

How I turned simulated production traffic into reviewed test cases, then ran them in CI to check changes to an AI agent.

By

No. 14

Evaluations · Part 3

A coral customer-message card joins checked cards in a blue filing box.

I built a workflow that turns recorded customer requests into test cases, then runs those tests automatically when I propose changes to the agent’s code or instructions.

The shop and its customers are still simulated. In production, reviewing customer requests can show where an agent went wrong or where the policy left it guessing. Those requests can then become tests for future changes.

This follows the same regression-testing loop as ordinary code: turn a production problem into a test, fix it and keep running it in CI. Here, each case exercises the agent’s whole workflow, using the code checks from part 1 and the model judge from part 2.

Recorded customer traffic, simulated here, feeds human review, where I write the expected outcome for new cases. Cases start as capability tests and can move into the regression suite after ten successful attempts. Both suites run overnight; regression tests also run on pull requests.

Capture the requests and what the agent did

I needed new customer requests outside the test cases I’d already written. So I wrote a script to create 200 scenarios using the simulated shop’s customer and order data, then asked Sonnet 5.5 to turn each scenario into an email. The emails used different writing styles and included missing order numbers, people writing about someone else’s order, and customers asking for a specific amount back. I also added ten more emails by hand.

I ran the same 210 emails through the agent twice, using Haiku 5.5 both times. One run used the shop’s existing instructions. In the other, I removed two instructions about checking the order and the sender. I wanted to see whether my checks would pick up on the agent turning customers away incorrectly. Vessel recorded the requests and responses between the agent and the model as it handled them, including the conversation, tool calls and tool results.

I used those recordings to rebuild the record my existing graders expected:

  • Part 1: the test runner collected the conversation and tool results, and read the shop’s state directly.
  • Here: I reconstructed that record from the captured traffic, using successful tool results to work out which refunds and referrals for human review had been reported.

In the simulation I could check my work. All 420 reconstructed records matched what the test runner collected, including the changes to the shop. In production we’d still be relying on what the tools reported.

I used Vessel because it already held those recordings. An application could collect the conversation and tool results directly instead. Either way, the checks need a complete record.

Select requests for review

A new customer request doesn’t come with a correct answer. But several code graders from part 1 can still check how the agent handled it:

  • Did it look up the order before moving money?
  • Did the ticket’s recorded decision match the reported outcome?
  • Did the refund amount match an item price, or a combination of item prices?
  • Did it repeat an action that had already succeeded?

I ran the code checks on every interaction and had the model judge from part 2 read about 10% of replies for problems such as promises the shop couldn’t keep. Across the two runs, the code checks flagged six distinct requests and the judge flagged five more. I picked nine unflagged requests at random, giving me 20 to review.

All six requests the code checks flagged revealed a problem. Of the five the judge flagged, one was a wrong decision in the run with weaker instructions. The other four were about what the agent told the customer. In one, it said it had checked the tracking information. It hadn’t.

The agent handled all nine random picks correctly in both runs. Because I’d generated the requests, I could also check all 20 emails about someone else’s order. With the weaker instructions, the agent turned down 11 of them when it should have asked for the account holder’s details. Only one reached me for review, through the judge. No money moved in those cases, and the code checks had no way to tell whether a refusal was justified.

Write down what should have happened

These requests were candidates for new tests. I still had to supply the label: the expected decision and changes to the shop that a future test would check against.

A tool showed me each customer’s email, the policy and the shop’s records. I wrote down what should have happened before seeing the agent’s answer or why the request had been selected.

One customer asked for $8 back on a scratched $40 lamp they wanted to keep. The agent paid it, and the amount check flagged the payment because it didn’t match an item price. But the policy hadn’t said whether the shop offered this kind of compensation. I had to decide that before I could write a useful test.

I chose to allow refunds for whole items or orders only, not compensation payments for customers keeping an item. I added that rule to the agent’s instructions.

I kept the customer’s original email as the test input. Here’s the part of the saved case that links it to the recording and says what should happen when I run it again.

{
  "source": "capture:16893",
  "expected": {
    "action": "denied",
    "order_id": "A2288",
    "amount": null,
    "refunds": [],
    "escalations": [],
    "note": "because we don't do compensation refunds."
  }
}

When I run that case, the agent gets a fresh copy of the simulated shop and handles the email again using its current instructions. To pass, it has to record the decision as denied and leave the shop with no refund or referral for that order.

Decide which cases must keep passing

New cases start as capability tests: behaviour I want the system to support, including things it can’t do yet. Once a case passes reliably, I move it into the regression suite: tests for behaviour that works and should keep working after changes to the agent’s code or instructions.

For this project, I required a new case to pass ten attempts out of ten before moving it across. Each attempt had to pass every applicable code check. That gave me a consistent entry rule, though it doesn’t guarantee the next attempt will succeed.

The lamp was one of four compensation cases. With the old instructions the agent failed all 40 attempts. With the new rule it passed all 40. I reran the 44 existing regression cases too, and all 440 attempts still passed.

Altogether, 18 of the 20 new cases met the entry rule, bringing the regression suite to 62 cases.

The other two needed the agent to refund one order and refer another for human review in the same request. The agent could do both, but the ticket-closing tool could record only one action. Those cases need a change to the tool’s design, so they stay in the capability suite.

Together with the 22 existing capability cases, that gave me 86 cases overall: 62 regression and 24 capability.

Run the regression suite in CI

I added a GitHub workflow that runs when I open a pull request. Changes to the agent’s code, instructions, test cases or related configuration all trigger the checks.

After the ordinary code checks, the workflow runs all 62 regression cases three times each. The agent can handle the same request differently each time. Three attempts give me a chance to see that, though an intermittent failure can still pass unnoticed.

I compare the results with a baseline: saved results from the accepted version of the agent. The gate, the check that must pass before accepting a change, has two rules:

  1. At least 95% of attempts must pass.
  2. A case that passed every attempt in the baseline must not fail all three attempts now.

The second rule stops a newly broken case disappearing inside a high overall score. If a previously passing case passes only one or two of its three attempts, it gets a warning. Those failures still count towards the overall pass rate. Missing results or errors contacting the model make the check fail as an incomplete run.

The ten-pass check decides which cases enter the suite; this shorter CI run checks subsequent changes. Up to nine of the 186 attempts can fail without blocking a change if the per-case rule doesn’t fire. Warnings still need review.

I chose 95% to demonstrate the workflow. I’d want several nights of results on unchanged code before choosing a threshold based on how often these tests usually fail. For checks protecting refund amounts or approval requirements, it should require every attempt to pass. Even then, passing the suite would be evidence about the tested cases, not a guarantee of zero failures in production.

To check the workflow, I submitted one change that removed the shop’s rule requiring human approval for refunds over $200. Seven previously passing cases failed on every attempt. That left 165 passes out of 186, so both rules blocked the change. A second change, adding a blank line to the instructions, passed all 186 attempts. Each pull request check took about 2¼ minutes including setup and cost about $0.12 in model calls.

GitHub Actions gate summary showing 165 of 186 attempts passing and all seven newly failing cases. Each went from 10/10 to 0/3 for the same reason: expected escalated, got refunded.

Removing the $200 approval rule made the agent issue refunds it should have referred to a human. The job summary names all seven affected cases.

Run the wider checks overnight

I kept the model judge out of the check that blocks changes. As part 2 showed, its verdicts can vary and need review. Instead, a nightly workflow runs every case, including the capability tests, and adds the judge’s assessment of the replies.

On a pull request Nightly
Cases 62 regression cases All 86 cases
Attempts per case 3 3
Checks Code graders Code graders and model judge
Purpose Check whether a change can be accepted Review reply quality and cases that still need work

The nightly report gives me replies to inspect for unsupported promises, as well as cases that aren’t ready to become regression tests. The judge’s verdicts need checking too: some of its failures were replies the policy allowed.

The nightly run tests the accepted code on main. Each pull request compares its results with the latest nightly run that completed without missing results or technical errors. If there isn’t one available, it uses a saved reference run from the accepted version instead.

The nightly results automatically become the new baseline. If a case passes only twice in three attempts overnight, it can fail all three on the next pull request and the change can still go through. I’d require a review before replacing the baseline.

The $8 lamp request gave me a clearer refund policy and a test that runs when I change the agent. When I removed the $200 approval rule, the regression suite caught it on the pull request. The two-action tickets stay in the nightly report until I fix the tool. As I review more traffic, I can add cases for the next problems I find.

Next: one test, eight toolboxes

So far I’ve written the code that runs the cases, checks the results and decides whether to block a change. In part 4, I take the same agent and a slice of these tests through eight well-known evaluation frameworks to see how much of that work they can handle, and what I would still need to check myself.