“The answers are bad” is a symptom, not a diagnosis. The most expensive mistake in a Claude system is fixing the wrong layer: rewriting a prompt when retrieval never surfaced the document, upgrading the model when a tool schema was rejected, or blaming hallucination on the generator when the source was never in context. The exam scenarios in this area usually give you a few observations and ask which layer is actually at fault, or which single step you should take next. The skill is to hold hypotheses in order of cost and to pick the test that separates them.
Before touching the prompt, collect evidence. For each failing case you want: the request-id of the response (every API response carries one; the Python and TypeScript SDKs expose it as _request_id); the full request as actually sent, including system prompt, tool definitions, message history, model ID and parameters such as effort and max_tokens; the full response including stop_reason and usage; the tool calls and tool results; the retrieved chunks with identifiers and scores; and the prompt version. Then reproduce the failure, reduce it to the smallest failing input, and only then choose a hypothesis. Lesson 1.4 covers how to capture this at scale; Lesson 7.3 covers the operational side in Claude Code environments.
The diagnostic tree, cheapest layer first
- Did the call succeed and finish? Read the status, the
error.typeand the message together. A 400invalid_request_errormeans the request was malformed and the model never ran, so nothing about model behaviour is implicated; a tool-call 400 is often a schema problem. 401 is a bad credential, 403 is a valid credential lacking access to that resource, 404 is often a wrong model ID, and 413 is an oversize request. These are deterministic: fix the request, do not resend it. 429 (a rate limit), 500 and 529 (overload) are the transient ones, and the official SDKs already retry transient failures with backoff, twice by default. A 429 caused by a tier spend cap is the exception: it has noretry-afterheader and keeps failing until access resumes, so it needs an alert, not a retry. Also check for truncation (stop_reasonofmax_tokensmeans the answer was cut off) and note that a streaming response can fail after a 200 has already been returned. - Did the tools and integration behave? Was the right tool chosen, with valid arguments? Did the tool return an error that was swallowed, or a result that was truncated or malformed? Overlapping or bloated tool sets degrade selection (Lesson 1.1).
- Was the needed information in the context? Test by pasting the known-correct source into the prompt. If the answer becomes right, the failure is retrieval or context assembly (chunking, index, query, freshness, trimming or cleared tool results), not the prompt or the model. See Lessons 1.5, 1.6 and 6.4.
- Is the prompt the problem? With correct context and a working call, look for ambiguous or conflicting instructions, missing criteria, an output format that is described but not shown, or an instruction buried among many. Iterate in small steps: name precisely what is wrong with a real failing output, make one targeted change, and re-run. You can ask Claude itself to diagnose, but give it the prompt and a concrete failing example; “make this better” with no example only produces guesses.
- Is the model or its configuration mismatched to the task? If the same prompt and gold context still fail, run the same case at a higher effort setting or on a stronger tier. If that fixes it, you have a capability or effort mismatch; if it does not, look upstream again.
Key concept: isolate by ablation
Change one layer at a time and hold the rest fixed: gold context instead of retrieved context, a stronger model instead of the current one, a targeted prompt edit instead of a rewrite. The layer whose substitution fixes the failure is the layer at fault. Each ablation is a small eval, so run it on a handful of failing cases, not one.
Hallucination: absent evidence or unfaithful use of evidence
A hallucination is plausible output that is not supported by the source or the facts. Treat it as a symptom with two very different causes.
- The truth was not available. Retrieval missed the document, the document was never indexed, or the context was trimmed. The model fills the gap with something plausible. The fix belongs to retrieval and to permission to abstain: Anthropic’s guidance is to explicitly allow Claude to say it does not know.
- The truth was available but not used faithfully. The claim contradicts or goes beyond the provided text. Here Anthropic’s techniques apply: for long documents ask Claude to extract word-for-word quotes first and answer only from them; have it cite a supporting quote for each claim and retract claims it cannot support; restrict it to the provided documents rather than general knowledge; ask for step-by-step reasoning before the answer; compare several runs, since inconsistency across outputs can signal fabrication.
The separating test is a groundedness check: does the wrong claim appear anywhere in the context that was sent? Anthropic’s own caveat is that these techniques reduce hallucination but do not eliminate it, so validate critical information for high-stakes use, and add a verification layer where consequences are serious (Lessons 4.2 and 4.3).
Model mismatch: capability, configuration and migration
Suspect the model when failures are consistent across reasonable prompt variants, when correct context is present, and when a stronger tier or higher effort setting fixes them. Anthropic’s guidance is to establish criteria, build evaluation sets specific to your use case, and compare models on accuracy, quality and edge-case handling rather than assuming; it also notes that tuning effort is often a better lever than switching models. Three mismatch patterns are worth recognising:
- Effort or tier too low for the task. Lower effort trades some capability for speed and cost, so complex multi-step reasoning can degrade. Set effort explicitly rather than relying on defaults.
- Migration breakage. A prompt tuned for one model may behave differently on another. The docs list concrete API-level examples: assistant-message prefill is rejected with a 400 on newer models, and the manual extended-thinking parameter is rejected on the newest ones in favour of adaptive thinking with effort. These show up as errors, not as quality drops, so read the message before blaming the prompt.
- Token accounting shifts. The docs note that newer tokenizers produce noticeably more tokens for the same text, so prompts near a context or cost limit can behave differently after a migration. Re-count against the target model.
Common exam distractor
The tempting answers are the ones that skip diagnosis: rewrite the whole prompt after one bad output, switch to the largest model, add “do not hallucinate” to the system prompt, or retry a 4xx request unchanged. Each fixes a layer you have not shown to be broken. The correct answer normally names the layer the evidence points to and the smallest test or change that targets it.
From single failures to a failure profile
One failure tells you where to look; a sample tells you where to invest. Label 20 to 50 real failures by root cause (call error, tool, retrieval, prompt, model, data or label problem), tally them, and fix the largest bucket first. Each fixed failure then becomes a permanent case in the evaluation set (Lesson 3.2) so it cannot return silently, and a disagreement between your labels and an automated grader is itself a finding about the grader.