A Model Explained with a Failing Test
Why This Matters
Most bad design decisions come from a wrong mental model: treating the model as a database, a rule engine, or a colleague who remembers yesterday’s conversation. In this lesson we follow one failing test through the model and replace those pictures with an accurate one. Everything else in the course builds on it.
The failing test
From fixtures/runs/run-1042.json:
checkout › applies a 10% discount code
Expected: "€90.00" Received: "€100.00"
GET /api/cart 200 {"subtotal":100.00,"discount":0,"total":100.00}
commit 8f3c2a1: refactor(pricing): move discount calculation to PricingService
history: passed, passed, passed, passed, passed
You can probably triage this in ten seconds: a refactor broke the discount. Let us see what the model does with it.
1. Text becomes tokens
The model does not read characters or words. Your text is split into tokens: short pieces of text, often part of a word. PricingService might become three tokens, €100.00 four or five. Tokens matter to you for two reasons: you pay per token, and every model has a maximum number of tokens it can consider at once.
2. The model predicts what comes next
Given all the tokens so far, the model predicts a likely next token, adds it, and repeats. That is all it does, and it is remarkably powerful: to predict a good triage, it has to use everything it learned about code, tests, logs and refactors. But it also means the answer is a likely continuation, not a looked-up fact.
3. The context window is all it knows
For this request, the model knows only what you sent: the system prompt, the messages and any tool results. It does not know your codebase, it cannot open the commit, it does not know the test failed yesterday unless you say so. If the evidence is not in the request, it is not in the model’s view. This is why TestPilot sends the history and the commit message along with the error.
4. No memory between requests
Ask a follow-up question in a new request (“why not flaky?”) and the model has no idea what it said before. Conversations only work because your code sends the earlier messages again, every time. You will build this in lesson 11.
5. Probable is not proven
Because the model picks likely tokens, the same failure can get a slightly different answer each time, and sometimes a different verdict. For a test tool that is a problem you need to measure, not ignore. In module 3 you run every case several times and keep the ones where TestPilot changes its mind.
6. Confident is not correct
A model can produce a log line that looks entirely plausible and was never in the input. It does not lie on purpose; a plausible line was simply a likely continuation. That is why TestPilot’s system prompt says quote the evidence exactly, and why in module 7 your code checks that every quote really exists in the input.
What this means for TestPilot
| How the model works | Design decision |
|---|---|
| Only knows the request | Send all evidence: error, log, history, commit |
| No memory | Keep conversation history in code |
| Predicts likely text | Measure consistency, use a golden set |
| Can invent plausible text | Demand exact quotes, verify them in code |
| Pays per token | Send only the relevant part of the log |
Try it
Run npm run triage (you need your key from lesson 3) and read the verdict for the discount test. Then ask yourself: which part of the input did it rely on, and would it have reached the same verdict without the commit line?