Skip to the page
Tecyfy

How AI works · beginner · About 8 minutes

The AI test that passes on Monday and fails on Tuesday

A test of an AI feature fails about 1 run in 6, and since a model upgrade it fails most runs. Nothing in the code changed. Find out why, and write a test that means something.

You maintain an app that uses a language model to sort refund requests.

What happened

Your app sends each refund request to a language model, which decides whether to approve it. A test checks one clear case: a parcel that never arrived must be approved.

The test has always failed now and then, and people re-ran it until it passed. Last week the team moved to a newer model. Now it fails on most runs, and nobody trusts the test suite.

The incident is made up. How things work in it is real, with sources at the end.

The evidence

Everything you need is here. Read it before you decide.

01The test(Code)
def test_lost_parcel_is_approved():
    reply = ask_model(
        "Customer says the parcel never arrived. Tracking shows no delivery. "
        "Should the refund be approved? Answer with the decision."
    )
    assert reply == "Refund approved."
02The last 4 runs(Log)
  1. Mon 09:12PASSRefund approved.
  2. Tue 10:40FAILApproved. The parcel was never delivered.
  3. Tue 10:44FAILRefund approved: tracking confirms no delivery.
  4. Tue 11:02FAILYes, approve the refund.
03The commit that came with the model upgrade(Note)

"Removed temperature=0 from ask_model. The new model returns an error 400 when temperature is set."

Your decisions

Decision 1 of 2

  1. Decision 1

    Why does the test fail when the code did not change?

The ideas behind it

LessonHow AI writes its answers: one piece at a time