Read the Request, Then Send It
Why This Matters
Testers read the test before they trust its result. Do the same with an API call: know every field you send before you judge what comes back. Most surprises in Claude applications are not in the answer; they are in a request nobody looked at closely.
The request, field by field
Open src/triage.ts. The whole call is one function:
const message = await client.messages.parse({
model: options.model ?? DEFAULT_MODEL,
max_tokens: options.maxTokens ?? 1024,
system: SYSTEM_PROMPT,
messages: [{ role: "user", content: buildTriageMessage(run, result) }],
output_config: { format: zodOutputFormat(triageResultSchema) },
});
| Field | What it does | Why TestPilot sets it this way |
|---|---|---|
model | Which Claude model answers | A capable default, overridable with TESTPILOT_MODEL |
max_tokens | Upper limit for the output tokens, including any thinking: current models think by default | Leave room: lesson 11 shows a verdict cut off at 1,024 |
system | Instructions that apply to the whole conversation | Role, categories and rules (lesson 10) |
messages | The conversation so far | One user message with the evidence |
output_config.format | The shape the answer must have | A schema your code can validate (lesson 9) |
The same request in the Console Playground
Build the request by hand in the Playground and read it before you run it: model, system prompt, the user message with evidence in XML tags, and the model settings.
Switch to Code and you see the request as code: the same fields as src/triage.ts.
Predict first
Before you run anything, write down your own verdict for each failure in fixtures/runs/run-1042.json:
| Test | Your verdict | Why |
|---|---|---|
| t-002 discount | ||
| t-003 login button | ||
| t-004 search suggestions | ||
| t-005 payment | ||
| t-006 avatar upload |
Predicting first turns the run into a test of the model, instead of letting the model’s answer anchor your opinion.
Run it
Press Run in the Playground. Claude cites the evidence, just as the system prompt asked.
Then run the whole fixture from your terminal:
npm run triage
This is a real run on run-1042:
Compare it with your predictions. Notice three things:
- Every verdict cites the evidence: the cart response, the renamed label, the 640 ms response time, the OOMKilled pod.
- Confidence follows the evidence. 0.92 for an outage with a health check and a pod event; 0.10 for the avatar test, where there is nothing to go on.
- The avatar test says
unknown. That is the system prompt’s “prefer unknown over a confident guess” at work. Lesson 10 shows what happens without it.
Read the response, not just the answer
Switch the Playground response to Raw and look at what your code receives:
stop_reason: why the model stopped.end_turnmeans it finished;max_tokensmeans it was cut off and your answer is incomplete.usage: input and output tokens, including tokens spent thinking and any cache activity. This is what you pay for.- The footer: the cost and the time of this single request.
Notice that this free-text answer is long: over a thousand output tokens for one failure. Lesson 9 fixes that.
Exercise
docs/exercises.md, lesson 8: compare TestPilot’s five verdicts with your predictions. Which one do you disagree with? Write down why, using only the evidence in the fixture. Keep your notes; you will need them for the golden set in module 3.
Show suggested answers
What the evidence in run-1042.json supports:
| Test | Verdict | Deciding evidence |
|---|---|---|
t-002 discount | product_bug | "applied":true but "discount":0, right after the PricingService refactor |
t-003 login | test_bug | The button is now “Sign in” (en.json changed in the same commit); the test still looks for “Log in” |
t-004 search | flaky | Failed 3 of the last 8 runs; the suggestions arrived 640 ms after the assertion |
t-005 payment | environment | ECONNREFUSED, sandbox health check 503, pod OOMKilled |
t-006 avatar | unknown | No history, no log, a generic toBeTruthy message |
The two that are worth disagreeing about:
t-004: flaky or test_bug? The timing makes it intermittent, but the root cause is a test that asserts before the data is there. “Flaky” describes the symptom, “test_bug” the fix. A good answer names both in the summary and picks the category your team acts on.t-003: test_bug or product_bug? Only if the rename was intended. The evidence says the label was changed on purpose inen.json, so the test is outdated. If nobody meant to rename the button, it is a product bug. The model cannot know intent; that is exactly the kind of case a human confirms.




