Prompt & Context Engineering·Question 32 of 68Intermediate

A user reports a bad answer. Walk me through how you debug it.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Reproduce, isolate, then change one thing. The order matters, and most people skip straight to rewriting prompt text.

Full worked answer with diagram

Reproduce, isolate, then change one thing. The order matters, and most people skip straight to rewriting prompt text.

Reproduce. I need the exact rendered prompt as the model saw it, the model id, the sampling params, the retrieved doc ids, and every tool call with its result. If my tracing does not give me that, the first fix is tracing, not the prompt. "The model ignored my instruction" is most often the instruction not being in the rendered string at all, or sitting 80k tokens above the question.

Check variance before believing anything. Run it five times. If it fails 1 in 5, this is a distribution problem, not a prompt bug, and no amount of rewording fixes it. That gets solved with constrained decoding, validation and retry, or a lower temperature. If it fails 5 in 5, it is deterministic and worth bisecting.

Bisect the context. Halve the documents, halve the examples, halve the rule list, and see if the failure survives. Drive to a minimal reproduction. This routinely finds that rule 7 contradicts rule 31, or that one example was teaching the exact wrong behaviour.

Root causes, roughly by frequency:

  • Retrieval failure. The answer was never in the context. Check this first, it is the most common by a wide margin, and it is not a prompt bug.
  • Contradictory or competing instructions.
  • The model pattern-matched an example instead of following the instruction.
  • A tool result was truncated or malformed.
  • Context rot from earlier turns: a stale error or an abandoned plan still sitting in history.

Asking the model why it did something is a useful diagnostic and terrible evidence. Its self-report is a plausible story, not an introspection log. Use it to generate hypotheses, then test them.

Only then do I change something, one thing, and re-run the whole eval set rather than the single case. Fixing the reported case while regressing four others is the default outcome otherwise.

Worth sketching. The variance branch is the one interviewers wait for, because it decides whether prompt wording is even the right lever.

flowchart TD
    A["Bad answer reported"] --> B["Pull rendered prompt,<br/>model, params, doc ids, tool calls"]
    B --> C{"Was the answer<br/>ever in the context?"}
    C -->|"no"| D["Retrieval failure,<br/>not a prompt bug"]
    C -->|"yes"| E["Re-run it five times"]
    E -->|"fails 1 of 5"| F["Distribution problem: constrain,<br/>validate, lower temperature"]
    E -->|"fails 5 of 5"| G["Bisect documents,<br/>examples, rule list"]
    G --> H["Minimal reproduction"]
    H --> I["One change,<br/>then the full eval set"]

What a good answer covers

  • Reproduce, isolate, then change one thing
  • The order matters, and most people skip straight to rewriting prompt text
  • I need the exact rendered prompt as the model saw it, the model id, the sampling params, the retrieved…
  • If my tracing does not give me that, the first fix is tracing, not the prompt
  • "The model ignored my instruction" is most often the instruction not being in the rendered string at…

Key terms: Reproduce · Check variance before believing anything · Bisect the context · Root causes, roughly by frequency

Interviewer follow-ups to expect

  1. How would you tell context rot apart from a retrieval failure from a trace?

  2. What do you do when the failure only reproduces at 1 in 50?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep