Interview Process & Behavioral·Question 15 of 56Intermediate

How do you debug non-deterministic bugs in LLM systems?

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

What they're probing: whether you've developed a real methodology for the defining operational annoyance of LLM systems - bugs that reproduce 7% of the time - or you just rerun things and hope. Strong answers convert non-determinism from mystery into statistics.

Full worked answer with diagram

What they're probing: whether you've developed a real methodology for the defining operational annoyance of LLM systems - bugs that reproduce 7% of the time - or you just rerun things and hope. Strong answers convert non-determinism from mystery into statistics.

Strong answer structure: first, separate the determinism layers: true randomness (sampling temperature), infrastructure non-determinism (batching effects, provider-side model updates, floating-point non-associativity even at temperature 0), and input variance masquerading as randomness (retrieval returning different chunks, context assembled in different orders). Then your toolkit: capture-everything logging so any production request can be replayed exactly; pinning what's pinnable (seeds where supported, dated model snapshots rather than floating aliases, temperature 0 for diagnosis where the API still exposes it - many reasoning models fix or ignore sampling parameters); and treating flaky behaviour statistically - run the failing case N times, measure a failure rate, and test whether candidate fixes move that rate significantly.

Example sketch: "A tool-calling agent intermittently skipped a required lookup step - roughly 1 in 15 runs. Step one was making it reproducible-ish: we logged full request payloads, so I replayed the exact context 50 times and got an 8% skip rate - now it's a measurable quantity, not a ghost. Diffing skip vs. success traces showed the failures correlated with a specific tool result landing near the context's end. Hypothesis: instruction dilution with long contexts. Fix candidates were each run 100 times against the replay: moving the instruction into the tool description cut skips to under 1%. Shipped that, added the scenario to evals with a 2%-failure-rate alarm threshold."

Pitfalls: "set temperature to 0" as the complete answer - it doesn't eliminate provider-side variance and isn't a fix, it's a diagnostic; no logging story, meaning nothing is replayable and every bug is unfalsifiable; single-run conclusions ("I changed the prompt and it worked once"); not knowing that providers repoint floating model aliases to new snapshots behind a stable name.

Worth sketching. It turns a ghost into a measured rate, which is the whole move, and the loop back to the hypothesis is where the work actually happens.

flowchart TD
    A["Flaky failure,<br/>roughly 1 in 15"] --> B["Replay the logged<br/>request 50 times"]
    B --> C{"Reproduces at<br/>a stable rate?"}
    C -->|"no, only in production"| D["Input variance: retrieval<br/>or context assembly order"]
    C -->|"yes, 8%"| E["Diff failing traces<br/>against passing ones"]
    E --> F["Hypothesis"]
    F --> G["100 replays<br/>per candidate fix"]
    G -->|"rate unchanged"| F
    G -->|"under 1%"| H["Ship, add eval case,<br/>alarm at 2%"]

What a good answer covers

  • What they're probing: whether you've developed a real methodology for the defining operational annoyance…
  • Strong answers convert non-determinism from mystery into statistics
  • Strong answer structure: first, separate the determinism layers: true randomness (sampling temperature),…
  • Then your toolkit: capture-everything logging so any production request can be replayed exactly; pinning…
  • Example sketch: "A tool-calling agent intermittently skipped a required lookup step - roughly 1 in 15 runs

Key terms: What they're probing · Strong answer structure · Example sketch · Pitfalls

Interviewer follow-ups to expect

  1. How do you write regression tests for behaviour that's correct 95% of the time?

  2. A bug appears in production but never replays locally - what's different?

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