Skip to content
Claude Certified Architect – Professional (CCAR-P) Exam Prep

Lesson 20 of 31 · 7 min

x
20/31

Debugging LLM System Failures

Video lesson: CCAR-P 20/31: Debugging LLM System Failures

Failure taxonomy (design guidance)

SymptomLikely layer
Wrong or missing factsContext or retrieval (the information never reached the model)
Ignores a rulePrompt (conflict, burial, too long) or a rule that needed enforcement
Calls the wrong tool or wrong argumentsTool interface (descriptions overlap, schema unclear, too many tools)
Truncated or malformed outputLimits (max_tokens, schema, streaming parsed early)
Good in testing, bad in productionData drift, different inputs, prompt or model version mismatch
Intermittent failuresNon-determinism, transient tool or API errors, race conditions
Cost or latency spikeCaching broke, context bloat, retries, agent loop growth
Confident but wrongHallucination (grounding, retrieval, validation gaps)
Refuses unexpectedlySafety refusal, prompt wording, reasoning_extraction pattern

Method (design guidance)

  1. Reproduce with the exact inputs, prompt version, tool results and model; capture the full request and response.
  2. Read the evidence: stop_reason, usage (including cache fields), tool calls and results, and the final text. Check stop_reason first (truncation, refusal, context overflow) (1.1).
  3. Isolate the layer by changing one thing at a time: give the correct context directly (does it now work?), simplify the prompt, replace a tool with a stub, swap the model tier, lower temperature or effort.
  4. Form a hypothesis, then test it against several cases, not one.
  5. Fix at the right layer (enforce in code if a prompt rule must hold; fix the tool description if selection is wrong; fix retrieval if facts are missing).
  6. Add a regression case and re-run the suite (D4.1).

Useful tooling

  • Claude Code: claude --debug shows parse errors (for example invalid rule frontmatter); /doctor prompt-audit audits instruction files (CLAUDE.md, rules, skills, commands, subagents) for problems; /mcp shows server status.
  • Hooks can log every tool call and result for later inspection (1.5).
  • Telemetry (OpenTelemetry traces and events) reveals which tool, which step and how long (D3.4).
  • Hook not firing? Check event name case, matcher against the tool name (not path), and whether max_turns ended the session first (1.5).
  • Empty end_turn after tool results? Text added after tool_result blocks can teach the model to end its turn.

Common root causes worth checking first

  1. Missing or stale context (retrieval miss, truncated history).
  2. Overlapping tool descriptions.
  3. Contradictory instructions across prompt layers or files.
  4. max_tokens too low.
  5. Cache invalidation from changing tools or tool_choice mid-session.
  6. A model upgrade with an unchanged prompt.

Exam traps

  • Rewriting the whole prompt instead of isolating the layer.
  • Debugging from one example.
  • Blaming the model when the context lacked the answer.
  • Fixing a hard requirement with a stronger prompt.
  • No regression test after the fix.

References

  1. Handling stop reasons — checked Oct 16, 2026
  2. Prompt caching — checked Oct 16, 2026
  3. Hooks in the SDK — checked Oct 16, 2026
  4. How Claude remembers your project — checked Oct 16, 2026

Check your understanding

  • First thing to check when output ends mid-sentence?Show answer

    Answer

    stop_reason; likely max_tokens or context limit.
  • The model "ignores" a policy it was told. Fix?Show answer

    Answer

    Check for conflicts or burial; if it must always hold, enforce in code or a hook.
  • How do you prove a fix works?Show answer

    Answer

    A regression case in the evaluation suite that failed before and passes after.
Previous

Progress is saved in this browser.

Next Lesson