Prompt & Context Engineering·Question 58 of 68Quick-fire

How do you debug a prompt that works most of the time but fails intermittently?

Quick-fire answer from the Awesome Generative AI Guide (MIT)

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

First reproduce and categorize the failures against a small labeled set instead of eyeballing one bad output. Isolate the cause: is it ambiguous instructions, missing context, a formatting issue, temperature-driven variance, or genuinely hard inputs. Fix the highest-leverage cause (tighten the instruction, add a schema, lower temperature, improve retrieval, add a targeted example) and re-run the eval to confirm the failure rate dropped without regressing other cases. Treat prompts like code: change one thing, measure, keep a regression set.

Full worked answer

First reproduce and categorize the failures against a small labeled set instead of eyeballing one bad output. Isolate the cause: is it ambiguous instructions, missing context, a formatting issue, temperature-driven variance, or genuinely hard inputs. Fix the highest-leverage cause (tighten the instruction, add a schema, lower temperature, improve retrieval, add a targeted example) and re-run the eval to confirm the failure rate dropped without regressing other cases. Treat prompts like code: change one thing, measure, keep a regression set.

Learn more: Prompting topic

What a good answer covers

  • First reproduce and categorize the failures against a small labeled set instead of eyeballing one bad output
  • Isolate the cause: is it ambiguous instructions, missing context, a formatting issue, temperature-driven…
  • Fix the highest-leverage cause (tighten the instruction, add a schema, lower temperature, improve…
  • Treat prompts like code: change one thing, measure, keep a regression set

Key terms: Learn more

Quick-fire answer from the Awesome Generative AI Guide (MIT) · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep