Skip to the page

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

Sources

Where each fact comes from

This page was last checked against these sources on 14 October 2026.

  1. 1
    Glossary

    Anthropic, Claude API documentation · 14 October 2026

    Temperature controls how random the model's predictions are. Higher values give more varied output and lower values give more predictable output. Even with temperature set to 0 the results are not fully the same every time.

  2. 2
    Claude Platform release notes

    Anthropic · 14 October 2026

    Setting temperature, top_p or top_k to a non-default value returns a 400 error on Claude Opus 4.8, as on Opus 4.7, and Claude Sonnet 5 and Claude Haiku 5.5 return 400 for non-default temperature too.

  3. 3
    Gemini API release notes

    Google · 14 October 2026

    On 21 July 2026 the sampling parameters temperature, top_p and top_k were deprecated in the Gemini API.

  4. 4
    Generation strategies

    Hugging Face, Transformers documentation · 14 October 2026

    Sampling picks a token at random according to the model's probabilities, so every token with a chance above zero can be chosen.