RAG error handling is the design of what a retrieval system does when something goes wrong, so that users get a useful response instead of a crash, a hallucination, or a silent wrong answer. Retrieval fails in more ways than most teams expect, and the system that has no plan for failure will invent one at the worst possible moment. The short answer is that every failure mode needs a named fallback, and the fallback must be safer than the failure it replaces.
This matters because retrieval systems sit between users and the truth. When the vector store is down, the embedding API times out, or the retrieval returns nothing relevant, the language model is still ready to answer, fluently and confidently, from nothing. That is the worst outcome: not an error message, but a plausible answer with no grounding at all. This article maps the failure modes, explains the fallback for each, and shows how to degrade gracefully instead of failing loudly or silently.
Key takeaways
- RAG error handling must cover every layer: embedding, retrieval, reranking, generation, and the stores underneath them.
- The most dangerous failure is not an outage but a silent one, where the model answers confidently from no evidence.
- Every failure mode needs a named fallback, and the fallback must be safer than the failure.
- Retries help with transient errors and hurt with persistent ones, so use backoff and circuit breakers.
- Never present an ungrounded answer as if it were retrieved; say what happened instead.
The Failure Modes You Actually Face
Embedding failures come first in the chain. The embedding API can time out, return an error, or silently return vectors from a changed model. A timeout is visible and retryable. A changed model is not, which is why embedding drift monitoring belongs in your error handling design as well as your quality monitoring. If the query cannot be embedded, retrieval cannot run, and the system must decide what to do without it.
Retrieval failures come next. The vector store can be unreachable, slow, or returning empty results. Empty results are the tricky case, because they are not an error at the infrastructure level. The store answered correctly: nothing matched. But an empty result set passed silently to the model produces an ungrounded answer, so the system must treat low retrieval quality as a failure in its own right, not as a normal input to generation.
Reranking and filtering failures are quieter. A reranker can time out, a metadata filter can exclude everything by mistake, or a permission filter can be misconfigured so that a user sees nothing they should see, or everything they should not. These failures rarely raise exceptions, which is why they need explicit checks: if the reranker fails, the system should fall back to the original ranking rather than failing the whole request or skipping reranking silently.
Generation failures close the chain. The language model can time out, hit a rate limit, return a malformed response, or produce an answer that contradicts the retrieved context. A malformed response is a parse error and can be retried. A contradictory answer is a quality failure, and the honest response is to tell the user that the system could not produce a grounded answer, rather than serving the contradiction. Failure analysis is the practice of tracing these modes to their causes, and it starts with the same failure inventory this article builds.
Design Principles for Graceful Failure
The first principle is to fail in the direction of honesty. When the system cannot ground an answer, it should say so. A message such as “I could not retrieve reliable sources for this question, so I cannot give a grounded answer” is far better than a fluent paragraph built on nothing. Users forgive an honest refusal. They do not forgive an answer they later discover was invented.
The third principle is that retries are for transient errors only. A timeout or a rate limit is worth retrying with backoff. A persistent error, such as a bad request or an authentication failure, will fail the same way every time, and retrying it only wastes time and money. Circuit breakers formalise this: after a run of failures, the breaker opens, requests fail fast instead of piling up, and the system recovers sooner. Retrieval latency is closely tied to this, because retries and timeouts are where latency budgets are usually spent.
The fourth principle is to set timeouts at every layer and make them add up. The embedding call, the vector search, the reranker, and the generation call each need their own timeout, and the total must fit inside the timeout the user experiences. A system with no per-layer timeouts is a system where one slow dependency can hang every request. Fault tolerance is the broader discipline here, and the same ideas apply: isolate faults, bound their impact, and recover quickly.
Fallbacks for Each Failure Mode
| Failure | How you detect it | Fallback | What the user sees |
|---|---|---|---|
| Embedding API timeout | Call exceeds its timeout | Retry with backoff, then cached embedding if available | Answer, or an honest “unavailable” message |
| Vector store unreachable | Connection error or timeout | Circuit breaker opens; serve from cache or fail honestly | Stale cached answer flagged as such, or refusal |
| Empty retrieval results | Zero results or scores below threshold | Broaden query, lower threshold, try keyword search | Answer with weaker evidence, clearly labelled |
| Reranker failure | Timeout or error from reranker | Use original retrieval ranking | Normal answer, slightly lower quality |
| Model timeout or rate limit | Error or timeout from model API | Retry with backoff, then queue or refuse | Brief wait, or a clear retry message |
| Contradictory answer | Faithfulness check fails | Refuse to answer or summarise sources only | Sources shown without an invented conclusion |
| Permission filter error | Filter returns nothing for an authorised user | Fail closed and alert, never fail open | “Unavailable” message, never another tenant’s data |
Best for most teams: implement the fallbacks for empty retrieval and reranker failure first, because they happen most often and are the easiest to get wrong. Then add circuit breakers around the embedding and model APIs, where a persistent failure can cascade into a full outage.
Timeouts, Retries, and Circuit Breakers
Timeouts should be set deliberately, not left at library defaults. A good starting point is a per-layer timeout that is a fraction of the total user-facing budget: if the user waits ten seconds, the embedding call might get two, the vector search two, the reranker one, and generation five. Those numbers should be measured, not guessed, and they should be revisited as the system changes. A timeout that is too short causes failures under normal load. One that is too long lets a slow dependency consume the whole budget.
Retries should use exponential backoff with jitter, so that a recovering service is not hit by a synchronised wave of retries. Two or three attempts are usually enough; more than that rarely helps and often hurts. Retries should also be idempotent where possible, so that a retry does not create a duplicate side effect. And retries must be bounded by the total timeout, so that the retry loop cannot itself become the delay.
Circuit breakers protect the system when a dependency is genuinely down. After a configurable number of consecutive failures, the breaker opens and calls fail immediately, without waiting for a timeout. This frees resources, stops retry storms, and lets the system serve its fallback path quickly. The breaker closes again after a cool-down period, with a trial request to check whether the dependency has recovered. System scalability work depends on the same mechanisms, because a system that cannot shed load gracefully cannot scale either.
Monitoring Errors So They Get Fixed
Every failure and every fallback should be logged with the same request ID used by the audit trail, so that a bad answer can be traced to the exact failure that caused it. The metrics that matter are the rate of each failure mode, the rate at which each fallback is used, and the rate at which fallbacks themselves fail. A fallback that is used constantly is not a safety net; it is the system telling you that the primary path is broken.
Alerting should distinguish between transient and persistent failures. A handful of timeouts an hour is normal. A sudden spike, or a steady climb over days, is a signal that a dependency is degrading or that traffic has outgrown a limit. Alerts should fire on the persistent pattern, not on every individual failure, or the team will learn to ignore them. Production architecture treats error handling as a first-class concern, and the monitoring that goes with it is what separates a demo from a system that survives real traffic.

Error Handling Checklist
- List every failure mode for each layer: embedding, retrieval, reranking, generation.
- Give every failure mode a named fallback, and make the fallback safer than the failure.
- Treat empty or low-quality retrieval as a failure, not as a normal input.
- Fail honestly when no grounded answer is possible; never present invention as retrieval.
- Set a timeout for every layer, and make the total fit the user-facing budget.
- Retry transient errors with backoff and jitter, at most two or three times.
- Put circuit breakers around the embedding and model APIs.
- Fail closed on permission errors, never open.
- Log every failure and fallback with the request ID, and alert on persistent patterns.
- Test failure modes deliberately with fault injection, not just by waiting for them.
Frequently Asked Questions
What is the worst failure mode in a RAG system?
A silent one: retrieval returns nothing useful, and the model answers fluently from no evidence. The user receives a confident, ungrounded answer, and nothing in the system records that anything went wrong. Guarding against this is the first job of error handling.
Should the system retry a failed embedding call?
Yes, for transient errors such as timeouts and rate limits, with backoff and a small number of attempts. No, for persistent errors such as authentication failures or bad requests, which will fail the same way every time.
When should a circuit breaker open?
After a run of consecutive failures that suggests the dependency is down rather than briefly slow. The exact threshold depends on your traffic, but the principle is the same: stop calling a service that is failing, fail fast, and serve the fallback instead.
Is it acceptable to show a cached answer when retrieval is down?
Yes, if the answer is clearly labelled as cached and dated, so the user knows it may be out of date. Serving a stale answer silently is misleading, but serving one transparently is a reasonable degradation.
What should happen if the permission filter fails?
The system must fail closed: refuse the request and alert, rather than returning unfiltered results. Failing open on a permission error can expose one tenant’s data to another, which is far worse than a temporary outage.
How do I test error handling before production?
Use fault injection: deliberately make the embedding API slow, the vector store unreachable, and the reranker fail, then check that the fallbacks engage and the user sees an honest response. Testing failure modes in staging is far cheaper than discovering them in production.
RAG error handling is not about preventing failure. Failure is guaranteed, in every layer, sooner or later. It is about deciding in advance what happens next, so that the system’s worst day produces an honest refusal instead of a confident invention. List the failure modes, name the fallback for each, bound the retries, and test the whole thing by breaking it on purpose. The systems that survive production are not the ones that never fail. They are the ones that fail well.







