When an LLM application becomes slow, starts failing, or returns unusable answers, the fastest path to recovery is a consistent diagnosis rather than a prompt change made on instinct. This guide provides a production troubleshooting workflow, a symptom-to-cause table, the telemetry to capture, and a recurring review schedule for separating provider errors, rate limits, retrieval failures, prompt regressions, timeout problems, and malformed outputs.
Overview
LLM production issues usually occur across several layers at once. A request may pass through your user interface, application server, retrieval pipeline, model API, tool-calling layer, output validator, and database before a response reaches the user. Treating every failure as a “bad prompt” can hide the real cause and make incidents harder to reproduce.
Begin by identifying the failing stage. Ask four initial questions:
- Did the request leave your application and reach the model provider?
- Did the provider return a response, an error, or no response before the timeout?
- Was the retrieved context, tool result, or conversation history correct and within the intended limits?
- Did the response satisfy the format and business rules expected by downstream code?
Use a correlation ID for every user request and carry it through retrieval, model calls, tool calls, validation, and persistence. This lets an engineer compare a slow request with a successful request instead of relying on incomplete application logs. For retry strategy, deadlines, and idempotent request handling, see the LLM API Reliability Guide.
Do not change several variables during an active incident unless necessary. First preserve evidence: the deployed model identifier, prompt version, request shape, relevant input metadata, provider response, and timing breakdown. Redact sensitive content before storing or sharing logs.
What to track
Symptom-to-cause troubleshooting table
| Symptom | Likely causes | First checks |
|---|---|---|
| Requests are consistently slow | Large prompts, slow retrieval, queueing, long generation, or an overly generous timeout | Compare time to first token, generation time, retrieval time, input and output token counts, and model route |
| Latency suddenly increases | Provider degradation, traffic growth, a deployment change, retry amplification, or a new prompt path | Compare the incident window with baseline traffic, retry counts, model version, region, and release history |
| Many requests receive rate-limit errors | Request or token limits, traffic bursts, synchronized retries, or insufficient capacity planning | Inspect status codes and provider headers where available; group errors by model, account, route, and time |
| Some calls fail with authentication or permission errors | Expired credentials, incorrect environment configuration, disabled access, or a changed model identifier | Verify the deployed secret reference, account, project, endpoint, and model access without exposing credentials |
| Answers cite irrelevant or missing information | Retrieval failure, poor chunking, stale indexes, filters excluding evidence, or context truncation | Inspect retrieved documents, scores or ranking signals, filters, chunk sizes, and the final context sent to the model |
| Responses are fluent but incorrect | Ambiguous instructions, unsupported assumptions, weak grounding, prompt regression, or missing validation | Run a known test set and compare the prompt, context, model route, and evaluator results with the last good release |
| JSON or tool arguments fail to parse | Unconstrained output, schema mismatch, truncated generation, invalid escaping, or a changed tool definition | Save the raw response, validate against the current schema, check finish status, and compare schema versions |
| Only long conversations fail | Context overflow, excessive history, duplicated instructions, or memory assembly errors | Measure each context component and review truncation behavior; use the context window management guide |
Logging fields checklist
Capture enough information to reconstruct a request without creating an unnecessary store of sensitive text. A practical event record includes:
- Identity: correlation ID, request ID, service name, environment, deployment version, and timestamp.
- Routing: provider, endpoint, region if relevant, model identifier, fallback route, and API or SDK version.
- Prompt state: system, developer, and user prompt version identifiers; template variables; input and output token counts where available; and truncation flags.
- Pipeline timing: queue delay, retrieval duration, time to first token, generation duration, tool-call duration, validation duration, and total time.
- Outcome: HTTP status or provider error category, retry count, timeout flag, finish reason, validation result, and user-visible fallback.
- Retrieval and tools: index or data source, number of retrieved items, filter settings, tool name, argument validation result, and tool execution status.
- Cost and capacity signals: token usage, concurrency, rate-limit signals, and approximate request class. Apply access controls and redaction to these records.
For structured responses, keep the raw model output separate from the parsed object. A parser error should not erase the evidence needed to identify whether the model, schema, transport, or application caused the failure. The structured output guide covers validation and recovery patterns.
Cadence and checkpoints
Production troubleshooting is easier when teams review reliability before an incident. Use three complementary checkpoints.
Per request
Record the correlation ID, route, duration breakdown, token usage, outcome, and validation status. Sample or hash sensitive content rather than logging full prompts by default. Keep enough metadata to group failures by prompt version, model, tenant, feature, and release.
Weekly or release-based
Review a small, stable evaluation set after prompt, retrieval, model, schema, or orchestration changes. Track latency percentiles, error categories, timeout rate, retry volume, valid structured-output rate, tool success rate, retrieval coverage, and task-specific quality. Do not combine all failures into one success percentage: a transport error and an incorrect answer require different fixes. For test-set design and evaluation workflow, use How to Evaluate LLM Apps.
Monthly or quarterly
Perform a broader reliability review. Compare traffic patterns, token consumption, provider or model routes, fallback frequency, prompt versions, and the distribution of user complaints. Check whether timeout values still match the user experience, whether retries are multiplying load, and whether dashboards still reflect the current architecture. Revisit cost and token assumptions with the LLM API cost guide.
Maintain a short change register. Record the date, change type, affected feature, expected effect, observed result, and rollback decision. This makes prompt regressions and retrieval changes visible alongside ordinary software releases.
How to interpret changes
Look for relationships, not isolated numbers. A latency increase accompanied by larger input tokens suggests context growth; a latency increase with stable tokens and higher retry counts suggests transport, capacity, or rate-limit pressure. A rise in invalid JSON after a schema change points toward contract drift, while a rise in irrelevant answers with stable transport metrics points toward retrieval or prompt behavior.
Separate user-visible latency from provider latency. The model call may be quick while retrieval, tool execution, serialization, or queueing consumes most of the request budget. Break the total deadline into stages and set a clear policy for partial results, fallback responses, and cancellation.
For errors, group by stable categories rather than raw message text. Provider messages can vary, and SDKs may wrap or rename errors. Store the original status and response metadata, then map it to internal categories such as authentication, permission, rate limit, timeout, invalid request, provider availability, parsing, retrieval, tool execution, or application logic. Recheck that mapping when changing providers or SDK versions.
For poor responses, compare a failing example with a known-good example. Diff the model route, prompt version, retrieved context, conversation history, tool results, output constraints, and post-processing. If the evidence is not present in the supplied context, changing wording alone is unlikely to solve a grounding problem. If the answer is grounded but violates a format contract, strengthen validation and recovery instead of silently accepting it.
Incident runbook template
- Declare: name the affected feature, start time, severity, owner, and communication channel.
- Scope: quantify affected requests by route, model, tenant, region, release, and error category.
- Stabilize: pause a problematic deployment, reduce concurrency, disable a nonessential tool, use a tested fallback, or adjust traffic routing.
- Diagnose: trace representative successes and failures using correlation IDs and timing breakdowns.
- Fix: apply the smallest reversible change and verify it against live telemetry and a fixed evaluation set.
- Close: document the cause, contributing conditions, user impact, detection gap, corrective action, and owner.
When to revisit
Revisit this troubleshooting guide whenever a provider changes error behavior, an SDK changes retry or timeout defaults, a model route changes, or your application adds retrieval, tools, streaming, or structured output. These changes can alter both the signals you need and the way failures appear.
At minimum, schedule a monthly operational check for active LLM applications and a deeper quarterly review for systems with meaningful traffic or business impact. Also review immediately after an incident, a prompt or model release, a sharp change in token usage, a recurring timeout pattern, or a new class of malformed responses.
End each review with three concrete actions: update the symptom table with newly observed failure modes, verify that dashboards and alerts use current field names and thresholds, and run the evaluation set against the deployed path. Keep the runbook, prompt versions, schema contracts, and provider-specific notes in the same maintenance process. That habit turns LLM troubleshooting from emergency guesswork into a repeatable part of AI application development.