SaaS technology
Businesses SaaS June 29, 2026 • 7 min read

LLM Prompt Failure Modes: A Diagnostic Cheatsheet

For: A product engineer at a 20–80-person B2B SaaS company who shipped an LLM-powered feature (summarization, extraction, or classification) that worked reliably in demos but now produces wrong, inconsistent, or refused outputs in production — and cannot tell whether the problem is the prompt, the model, the input data, or the temperature setting

Most production LLM failures are not model failures. They are prompt-contract violations: the input technically fit the token window but broke an implicit assumption the prompt was written against — clean formatting, one language, bounded length, no adversarial content, predictable structure. The symptom that shows up in production maps predictably back to which clause broke. Debugging becomes a lookup, not a tuning exercise.

This cheatsheet maps the failure modes we see most often in shipped summarization, extraction, and classification features, the root cause to check first, and the fix that actually holds.

The prompt contract: what your demo assumed

Every prompt that worked in a demo carries unwritten clauses. List them before you debug:

Production breaks at least one of these. The failure mode tells you which.

Symptom → root cause lookup

SymptomMost likely causeFirst thing to check
Output is correct in dev, wrong in prod on the same inputModel version drift or different system prompt in the prod pathLog model, temperature, system, and full message array from prod
JSON parse errors, trailing commas, markdown fences around JSONMissing structured output mode; instruction-only JSON contractSwitch to JSON mode / function calling / response_format schema
Output sometimes in a different languageInput contains non-English content; prompt doesn't pin output languageAdd explicit "Respond in English regardless of input language"
Extraction returns empty or null for fields that are clearly presentField name in prompt doesn't match how the model sees the data; or input was silently truncatedLog input token count vs. context window; rename field to match source vocabulary
Classification labels drift outside your enumNo constrained decoding; soft enum in prose promptUse function calling with enum, or post-validate and retry
Summaries hallucinate facts not in sourceInput too long → middle-of-context loss, or prompt rewards fluency over fidelityCheck input length; add "Only use facts present in INPUT. If unknown, write 'not stated'"
Model refuses or returns a safety messageInput contains PII, medical/legal terms, or injected adversarial textInspect the exact failing input; check for prompt injection patterns
Output quality degrades after a vendor updateSilent model upgrade (e.g., gpt-4o alias rolled forward)Pin to a dated snapshot; add a regression eval gate
Same input, different output each callTemperature > 0, or non-determinism even at 0 with some providersSet temperature to 0, set seed where supported, cache by input hash
Truncated mid-sentence outputmax_tokens too low for actual output distributionLog output token counts; size max_tokens to p99, not the mean
Latency spikes and timeouts on long inputsContext bloat from RAG or chat historyMeasure tokens per call; cap history; rerank/trim retrieved chunks
Works on short inputs, fails on long onesLost-in-the-middle: instructions at top, critical content buriedMove instructions to the end, or repeat key constraints after the input
User reports profanity, off-brand tone, or off-topic answersPrompt injection in user-supplied contentSeparate roles: put untrusted input in a user message with delimiters; never concatenate into the system prompt

Failure mode taxonomy

1. Contract violations (most common)

The prompt assumed something the input didn't deliver. Fix at the input boundary, not the prompt.

2. Output-shape failures

The model produced semantically correct content in the wrong structure. Always cheaper to constrain than to parse defensively.

3. Capability ceiling

The model genuinely can't do the task at the quality you need. Symptoms: failure is consistent across phrasings, persists at temperature 0, and a stronger model fixes it.

4. Non-determinism and drift

5. Prompt injection

Any field a user can write into is hostile. Treat retrieved documents the same way.

A debugging order that actually works

  1. Reproduce. Capture the exact failing input, model id, temperature, full message array, and output. If you can't reproduce, you can't fix.
  2. Diff against a known-good input. What changed — length, language, structure, special characters?
  3. Strip and rebuild. Run the failing input through a minimal prompt. If it still fails, it's an input or model problem. If it passes, it's a prompt problem.
  4. Constrain the output. Move from prose instructions to schemas before tuning wording.
  5. Escalate the model. If a stronger model also fails, decompose the task.
  6. Add a regression test. Every production bug becomes a fixed input/expected pair in your eval set.

What to log on every call

Without these, every incident is a guess. With them, most incidents are a SQL query.

Where this falls apart

This cheatsheet assumes you have a labeled eval set and a way to replay production inputs. If you shipped without either, fix that first — no diagnostic framework helps when you can't measure whether a change made things better or worse. Teams building production LLM features from scratch can see how we structure evals and observability in the AI Studio work.

Frequently Asked Questions

Why does my LLM output change between calls with the same input?

Three causes, in order of likelihood: temperature is above 0, the provider silently rolled the model alias forward, or you're hitting residual non-determinism that exists even at temperature 0 on some providers. Pin a dated model snapshot, set temperature to 0, set a seed where supported, and log the model id on every call so drift is visible.

Should I fine-tune or improve my prompt?

Improve the prompt first, then constrain outputs with schemas, then escalate to a stronger model, then decompose the task. Fine-tuning is the right answer when you've done all four and the failures are consistent, narrow, and you have a few hundred high-quality labeled examples. Most teams reach for it too early.

How do I stop the model from hallucinating facts in summaries?

Check input length first — facts most often go missing from the middle of long contexts. Add an explicit instruction to use only facts present in the input and to say "not stated" when unknown. Then validate by extracting claims from the output and checking each against the source; treat unverifiable claims as failures in your eval set.

How do I prevent prompt injection from user content?

Treat any user-supplied or retrieved text as hostile. Wrap it in delimited blocks, never concatenate it into the system prompt, place your trust-boundary instructions after the untrusted content, and allowlist any tool arguments the model can produce. Assume some injection will succeed and design downstream actions to be reversible.

Can you help us audit an LLM feature that's misbehaving in production?

Yes. Audits typically cover prompt structure, eval coverage, observability, model selection, and failure-mode regression testing. Contact CodeNicely for a personalized assessment based on your stack and the specific failures you're seeing.

Found this useful? CodeNicely publishes engineering and product playbooks weekly. Browse the archive or tell us what you're building.