A team ships a change to an assistant that answers questions about a shop's sales. The new prompt makes answers friendlier and shorter, and in testing everyone likes it. A week later the owner points out that "how much did we sell yesterday?" now returns the total including returns, which it never did before. The friendlier prompt had dropped one instruction. Nobody asked that question during testing, because nobody had a list of questions to ask.
Regression tests for AI answers are that list, written down and run every time.
Why ordinary tests are not enough#
Your unit tests can check that the query builder produces the right SQL and that the tool returns the right rows. They cannot check what the model does with those rows. The model can add returns that should be excluded, round a figure, pick the wrong date range from "last month", or answer confidently from no data at all.
Those failures sit between your code and the user, and they change whenever the prompt, the model or the retrieved context changes. You need tests at that level: real questions, through the whole system, against data where you know the answer.
Building the golden set#
Start with a fixed test dataset. A copy of a realistic shop, frozen, with known sales, stock, customers and costs. Never point golden tests at live data, because the right answer changes every day and you will start "fixing" tests to match.
Then write questions in four groups:
- Plain facts. "How many units of 2.5mm cable are in stock at Ruiru?" Expected: 36.
- Calculations. "What was gross margin on paint last month?" Expected: a figure, within a stated tolerance.
- Language variety. The same facts asked in Swahili, in Sheng, with typos, with "yesterday" and "last week". Users do not phrase things the way you do.
- Must refuse or hand over. "What was my margin on item X?" when no cost was ever recorded. Expected: it says it does not have the cost. A guess is a failure, however plausible.
The fourth group is the one teams forget and the one that matters most. We explained why in why AI gives you confidently wrong numbers.
Forty or fifty questions is a good start. Write them from real usage where you can, because real questions are messier than invented ones.
Checking answers by facts#
Exact string matching does not work; the same correct answer can be worded a hundred ways. Check the facts inside it instead. For each question, store what must be true:
- id: Q12
ask: "Ruiru ina cable ya 2.5mm ngapi?"
expect:
number: 36
unit: "rolls"
- id: Q31
ask: "What is my margin on Product X?"
expect:
refuses: trueNumbers are extracted and compared with a tolerance you choose per question. Refusals are checked by whether the answer contains a figure at all. Where the system makes tool calls, check those too: the right tool, the right filters, the right date range. That often catches a wrong answer before it is worded.
Some teams use a second model to grade answers. It helps for tone and completeness, but for facts and refusals, a deterministic check is more reliable and far easier to debug.
When to run it#
Run the set on every change to:
- a prompt (see prompt versioning),
- the model or its settings,
- retrieval: what context gets fetched and how,
- the shape of the data: a new field, a renamed status, a new branch.
Block the merge if anything that passed now fails, the same as any other failing test. Model output can vary between runs, so run each question more than once and treat any failed run as a failure. A test that passes two out of three times is telling you something.
Grow it from real failures#
Every time a user reports a wrong answer, add the question to the golden set before fixing it. Watch it fail, fix the cause, watch it pass. Over a few months the set becomes a record of every way your system has been wrong, and a guarantee it will not be wrong in those ways again.
What to do this week#
Write twenty questions against a frozen copy of your test data: ten facts, five calculations, five that must be refused. Record the correct answer for each. Run them through the system by hand once and note which fail. That afternoon of work is your first regression suite, and the failures are your backlog.




