A Different Story Every Night: What to Do When Neither the System Nor the Test Gives the Same Answer Twice

Article 3 of 6 in New Lamps for Old, a series on bringing AI into regulated financial processes.

By Alyona Bulda and Marina Kudriavtceva, Exactpro

Married to a king who executes each new wife at dawn, Shahrazad stays alive by telling him a new story every night and stops before it ends, so that he spares her for one more day to hear what comes next. Night after night, the tale breaks off with the same line:

"And Shahrazad perceived the dawn of day and ceased saying her permitted say."

The Book of the Thousand Nights and a Night, trans. Richard F. Burton, vol. I (1885)

The test that used to work

The second article in this series argued that a pilot reaches production only with evidence a risk committee can sign off on, and that tests are the only such evidence in the context when a system can give a different answer to the same question every time it is asked. This article looks at what those tests have to look like.

Software testing in financial markets rests on a simple assumption: the same input produces the same output. Send the same orders into a matching engine in the same state, and it must produce the same trade, every time. In market infrastructure, determinism is not a convenience, but a vital design requirement, and firms invest heavily in protecting it. That property is what makes testing manageable. A test has an expected result, and the system either matches it or fails. Regression testing means rerunning yesterday's tests and checking that nothing has changed. The resilience of the market infrastructure has been built on that discipline.

AI systems break that assumption. Ask a large language model (LLM) the same question twice and you may get two different answers, both plausible, one subtly wrong. Even setting a model to its most predictable configuration does not fully fix this: researchers at Thinking Machines Lab showed that LLM APIs are still not deterministic in practice at temperature zero, mainly because the result depends on how many other users' requests are processed alongside yours. A fix exists, but it makes the model slower, so it is not the default (Thinking Machines Lab, 2025). And the system itself changes: vendors update the model, the data it sees drifts, and a prompt that worked last month behaves differently this month. The same is true when AI is on the other side of the test: a model that generates test cases or judges test results may give a different verdict on the same run.

None of that makes AI untestable. It means the old definition of a passing test is no longer enough. The King did not judge Shahrazad on one story, he listened every night.

A thousand and one runs

Testing a non-deterministic system means replacing “Is this output correct?” with three better questions: “How often is the output acceptable?”, “What must never happen?”, and “How would we know if either changed?”.

This is less new than it sounds. Even before AI, what testers observed was not fully deterministic, even when the core logic was: timing, concurrency and message ordering across distributed components vary from run to run. At Exactpro, our answer has long been to treat test runs as data, collecting the output of thousands of test executions in a test database and checking requirements as analytical queries across all of it, rather than relying on a single test case per requirement.

“ “

We have spent years testing systems that do not necessarily behave exactly the same way twice – these are auctions, green-rooms and low-latency distributed platforms in general. The lesson carries over to AI: we are not looking at a single expected result, but treat every observation as a contribution to our knowledge and model of the system under the test. Confidence comes from relentless experimentation and the whole body of evidence, not from a green tick or a successfully passed pipeline.

In practice, answering those questions calls for six tools:

  1. Properties instead of exact answers. Many requirements can be written as rules that every output must satisfy, whatever its wording: every figure must reconcile to the source document, every answer must say where it came from, no recommendation may exceed a client's limits, no output may contain personal data it was not given. Invariable rules like these can be checked automatically, on every output.
  2. Distributions instead of single runs. Run each test case many times and measure the spread: how often the answer is acceptable, how often it is wrong, how often the system declines to answer. Acceptance becomes a threshold agreed in advance, not a single pass or fail. The same runs then become the baseline: repeat them after every model update, prompt change or a new data source, and compare the results with the baseline, not with a single expected answer.
  3. Metamorphic relations. Even when the right answer is unknown, you can know how the system's answer should behave when the input changes. Rephrase a question without changing its meaning, reorder the documents provided: the decision should not move. Metamorphic testing was developed for exactly this situation, programs with no reliable test oracle (where the correct answer is not known in advance), and researchers have applied it to machine learning for more than a decade (Xie et al, 2011).
  4. Adversarial testing. Deliberately try to break the system: inputs that try to override its instructions, requests designed to leak data, edge cases taken from the worst day in the history of the process. NIST's Generative AI Profile treats this kind of red-teaming as part of testing, evaluation, verification and validation (NIST, 2024).
  5. Comparison with the current process. The relevant question is rarely whether the AI is perfect, but whether it is better than what it replaces. Run it alongside the existing process on the same cases and compare error rates, including the errors people make today.
  6. Guardrails, tested like everything else. Put proper controls around the model: filters on what goes in, validators on what comes out, confidence thresholds that route uncertain cases to a person, human sign-off for high-impact decisions and hard limits on what the system is allowed to change. Then test those controls as deliberately as the model, by trying to get past them. As we put it in our first article, a guardrail is only as good as the testing behind it.
Shahrazad tells the King a new story every night

Who decides what is right?

Every test needs an oracle: something that establishes what the correct result is. For deterministic systems in the market infrastructure, the oracle is well-established: the exchange or CCP rulebook, the protocol and message specifications, and a regression library of thousands of scenarios with known outcomes, refined over years of releases, incidents and market events. Every new software version is measured against that library before it goes live. For AI, finding an oracle is often the hardest part of the work.

Sophie Lafont, who leads compliance and regulatory projects at an exchange, puts it plainly:

“ “

AI can only test against what someone has clearly written down, and in a highly regulated environment like finance, that work starts with the compliance team. They are not there only to run proofs of concept: when testing AI or testing with AI, they define what ‘correct’ means by turning each rule into a clear expected behaviour, and by marking where the rule leaves room for judgment. That judgment belongs to compliance experts who truly know the rules and can bridge the gap between the rule text and the system: they are the final guardians; their expertise is therefore essential to ensuring that AI is used in a controlled and accountable way.

The best test oracle is history. Processes with a record of known correct outcomes – resolved breaks, closed alerts, approved documents – come with a ready-made test set, which is why the first article in this series recommended starting where such a record exists. Where history is thin, firms rely on experts reviewing a sample of outputs, which is expensive and needs its own consistency checks. Increasingly, they also use one AI model to grade another. That can scale review, but the grader is itself a non-deterministic system: it needs testing too, and should never be the only check of something that matters.

Supervisors are already asking these questions, and firms are finding them hard to answer. In the UK, the PRA's model risk management principles, which apply to banks using internal models for regulatory capital, explicitly cover the risks of using AI and machine learning in modelling (PRA, 2026). In the Bank of England and FCA's 2026 survey, around two-fifths of respondents named “independent validation”, “ongoing monitoring and drift detection”, or “change control and versioning” as governance challenges. “Model behaviour and reliability” was among the risks firms were least likely to have mitigation controls for (Bank of England, FCA, 2026). Before a firm can say a model works, it has to decide who gets to say so.

Tim Thurman, who has run production and security at exchanges and market infrastructures, sets out what he needs before he signs off:

“ “

In every exchange and market infrastructure role I've held, I've been responsible for production and security, and no system has gone live unless I could defend it to regulators and clients. AI is no exception. Before approving it, I want independent test evidence that it operates within clearly defined limits across thousands of live market scenarios, including difficult conditions such as volatile openings, trading halts, and system failures, not just a controlled demonstration. Because AI may not give the same answer twice, I care less about any individual output than about the safeguards around it. I need strong controls that prevent it from acting beyond its limits, a complete record of every decision it makes, and the ability to switch it off immediately without disrupting the market. Finally, I believe AI has a real role in market infrastructure, but it must earn that role gradually. It should start in contained areas where errors can't reach the market and expand only as the evidence builds. There should be someone accountable for monitoring it daily, and we, not the vendor, should be able to explain what it did and why, when it gets something wrong.

The thousand-and-second night

A deterministic release that passes its tests keeps passing until someone changes the code. An AI system can change without anyone touching it: a vendor updates the model, the data shifts, users paraphrase their requests. Testing therefore has to continue in production – the same evaluation suite rerun on a schedule and on every change, sampled human review of live outputs, and alerts when the pattern of answers moves.

The Bank of England and FCA survey shows how far there is to go. As we noted in our second article, fewer than half of respondents always ran regression tests on high-materiality updates to vendor-provided models, and 25% always or usually let such updates flow into production automatically. Only 48 firms answered that question, so the figures should be read with caution, but the direction is clear (Bank of England, FCA, 2026). For a system that “tells a different story every night”, an unreviewed update is a new storyteller.

Turning the lamp around: AI in testing

The same technology can also be put to work on the testing itself, and for many firms that is where AI adoption starts. Our first article listed software testing among the best “first homes” for AI: feedback is fast and failures are visible. But the same article noted how few firms have taken it beyond pilots. Applied well, AI widens what testing can cover. It can generate scenarios from specifications and message standards such as FIX or ISO 20022, produce large volumes of realistic and adversarial test data, group failed runs by likely root cause and point out gaps in coverage. For non-deterministic systems, this matters more than ever: running every case many times, writing metamorphic variants and inventing adversarial inputs is work at a volume no team could produce by hand.

Good test data for financial AI is hard to come by, because the real thing is confidential and spread across firms. Regulators are starting to help. In November 2026, the Monetary Authority of Singapore and the Future of Finance Institute announced an AI Innovation Arena that will give developers a synthetic dataset that reflects interbank transaction and scam patterns pooled from five banks, to train and test AI models for scam detection (MAS and FFI, 2026).

But AI in testing is subject to the same rules as any other AI. A generated test is itself the output of a non-deterministic system. It can look thorough and check nothing that matters, and expected results generated by AI can simply copy the behaviour of the system under test, turning a wrong answer into a reference of correct behaviour. Six habits for establishing an enterprise-grade process:

  • Review what each generated test actually validates, not just whether it runs and passes.
  • Test the tests. Deliberately inject known faults and check that the test suite catches them.
  • Keep the oracle independent. Expected results should come from specifications, history or experts, never from the system being tested.
  • Manage test-generation tools like any other tool, with versioning and change control, so that a model update does not quietly change what is being tested.
  • Anchor everything to a trusted baseline. The foundation remains the firm's historical regression library, together with rulebook checks and independent validations, each examining the system from a different angle. Together they give a comprehensive view of how the system should behave. AI-generated tests add to that baseline; they never replace it. A new test that contradicts what the baseline already knows is a question to investigate, not a result, and anything only AI has checked has not yet been truly checked. That is what stops a flood of plausible but shallow auto-generated tests, sometimes called “AI slop”, from passing for coverage.
  • Measure the tool's own variation. Run the same generation or grading step more than once. If the AI produces different tests, or different verdicts on the same results, from one run to the next, treat that spread as part of the evidence, and never rely on a single run of a tool that might answer differently next time.

As our first article noted, Google's DORA research describes AI as an amplifier: it magnifies the strengths of high-performing teams and the dysfunctions of struggling ones (Google Cloud, 2025). Testing is no exception. A sound test strategy, with AI behind it, covers far more ground. A weak one simply gets faster at checking the wrong things.

Why the King kept listening

The King did not come to trust Shahrazad because one story was good. He trusted her because, night after night, every story was different yet each one stopped at dawn – and because he kept listening. That is what trust in AI has to look like: not a single pass, but evidence gathered continuously, against rules that never bend and thresholds agreed in advance.

The moral of the tale:

Don't ask whether the AI gives the right answer; ask how often it gives an acceptable one, what it must never do, how you would know if either changed, and who checks again tomorrow. And when AI does the testing, make sure it is never the only one checking.

Next in the series: “Open Sesame”, on data and governance: who holds the key, and what has to be in place before the door opens.

References