Stale RAG Answers: A Layer-by-Layer Decision Tree Across Cache, Vector Store, and Chunk Mapping
The most frustrating kind of complaint after a RAG system goes live is "I updated the document, why does it still answer with the old one?" This class of failure is different from "retrieval returns nothing": it is not that nothing came back, it is that something came back but it is outdated. The answer itself is fluent, confident, and even looks correct; it is just the version of the content from before the document was changed. Users accept it least of all, because "it can clearly answer, yet it answers with the stale version."
I have consolidated this kind of triage into three branches. The core is to establish one fact: a RAG answer crosses three layers before it reaches the user — the cache layer, the vector store, and the chunk mapping (document to chunk to vector) — and any one of them can be "the document changed but this layer did not." Walk the triage from the cheapest check up: cache first (ten seconds), then the vector store's timestamps (one query), then the chunk mapping (a grep and a compare). Put the expensive checks last, because many "stale answer" cases settle at the cache layer and never even reach the vector store.
Prerequisite: Confirm "where the answer came from" — without this log, everything after is guesswork
Before you can judge whether an answer is stale, you have to know whether this answer was computed fresh or pulled from cache. So the first step is not touching the store — it is emitting one "answer provenance" log line in the pipeline:
# Emit this one line before the RAG answer returns: did this hit cache or run full retrieval + generation
def answer_with_provenance(query: str):
cached = query_cache.get(semantic_key(query))
if cached is not None:
print(f"[provenance] query={query!r} source=CACHE")
return cached
ctx = retrieve(query) # full retrieval + generation
print(f"[provenance] query={query!r} source=FRESH topk={[c.doc_id for c in ctx]}")
return generate(query, ctx)
source=CACHE versus source=FRESH routes you straight into a branch of the decision tree:
Symptom: the document changed, the answer is still old
|
+-- (1) provenance = CACHE (hit the query / response cache)
| +-- Layer 1: cache not invalidated (the document change did not trigger cache clearing) -> fix the cache-invalidation policy
|
+-- (2) provenance = FRESH, but the retrieved chunk is old
| +-- the chunk's timestamp in the vector store is old ---> Layer 2: incremental ingestion picked up new documents only, not edits
| +-- an old chunk in the store was not deleted and a new one is also present -> Layer 2 variant: old and new chunks coexist, the old one ranks first
|
+-- (3) FRESH, the chunk in the vector store is new, but the answer is still old
| +-- the document changed but re-chunking was not triggered ----> Layer 3: chunk mapping broken (the old chunk holds the old vector slot)
| +-- in the top-K, the old chunk and the new chunk tie on score -> Layer 3 variant: retrieval pulled the old copy
|
+-- (4) FRESH, the whole top-K is new, yet the answer is still old
+-- generation layer: a hardcoded old example in the prompt / a few-shot carrying an old answer (back to generation, not storage)
One scenario I postmortemed (built from a typical production pattern): an internal knowledge-base RAG. An operator updated a device's configuration document, refreshed the page, and asked "how is this device configured now?" — and the answer was still the pre-edit version. The provenance log read source=CACHE: this answer had hit the query cache directly, it was the one computed and stored last time, and the document change never even came into play. The root cause was that the cache key used only the query text and did not fold in the document version or update time, so when the document changed the cache should have invalidated but did not. The fix was to append the document's version number to the cache key (or proactively clear the related cache when a document changes). The most expensive step in the whole triage was not the cache check, it was "emitting the provenance log first" — without that one line, you would have been going and touching the vector store and the chunking, all flailing on the wrong layer.
Layer 1: Cache not invalidated — "the document changed, the cache does not know"
Signature: provenance = CACHE, the answer comes straight from the cache. This layer is unrelated to the vector store or the chunking; it is "the last answer was stored, the document changed, but the cache did not invalidate with it."
# Confirm whether this hit the cache, and what the cache key looks like
grep -n "CACHE\|provenance" rag_app.log | tail -10
# Look at how the cache key is built (does it include a document version / timestamp?)
grep -rn "cache_key\|semantic_key\|cache.get" rag_app/ 2>/dev/null
Branching:
- The cache key holds only the query text, not a document version -> the document changed, the cache key stayed the same, and the old answer keeps getting hit. Fix: append the related document's version number or update time to the cache key, or proactively clear that document's cache when it changes.
- The cache key includes a version, but the TTL is too long -> the key has a version, but the old-version entry is still alive within the TTL, and a new query (if the version did not propagate into the cache key) still hits the old one. Fix: proactively invalidate on a document change; do not rely on the TTL to expire naturally.
- A semantic cache (hits by query similarity) crossed documents -> a semantic cache hits by "similar query," so an old answer to one changed document got "borrowed" by a similar question. Fix: a semantic-cache hit should carry back the "id of the document it hit," so a document change invalidates it, instead of looking at query similarity alone.
An independent judgment worth holding: cache invalidation needs a "proactive + version" double safety net, not TTL alone. Relying on TTL alone is "passively waiting for it to expire"; a document change has to wait out the whole TTL to take effect, and every moment in between is a stale answer. Proactive invalidation (a document-change event triggers the clear) plus a version in the cache key (the double safety net) shrinks the "stale answer" window from "one TTL" down to "one change delay."
Layer 2: Incremental ingestion picked up new documents only, not edits — "the document changed, the vector store did not refresh"
Signature: provenance = FRESH, but the timestamp of the retrieved chunk is old. This layer is "the document changed, but ingestion did not push the change into the vector store," and the typical root cause is that incremental sync processes "new documents" only and not "edits to existing documents."
# Look up, by doc_id, the timestamp of that chunk in the vector store and compare to the source mtime
# qdrant shown: fetch the doc's chunks and their payload timestamps
python3 - <<'PY'
import json, urllib.request
doc_id = "device-42"
pts = json.load(urllib.request.urlopen(
f'http://localhost:6333/collections/kb_chunks/points?limit=50&with_payload=true'))
for p in pts['result']['points']:
if p['payload'].get('doc_id') == doc_id:
print(p['payload'].get('updated_at'), '|', p['payload'].get('text','')[:40])
PY
# Compare against the source file: stat -c '%y' /data/kb/raw/device-42.md
Branching:
- The chunk's
updated_atin the vector store is older than the source document's mtime -> ingestion did not push the change in. The incremental sync picks up new documents only; an edit to an existing document never triggered a recompute. Fix: change ingestion to "decide whether it changed by the document's content hash / version," and when it changed, re-embed that document's chunks and delete the old chunks. - The new chunk made it into the store, but the old chunk was not deleted, so old and new coexist -> the incremental ingestion "adds but never deletes." New content sliced out a new chunk, the old chunk still holds its slot, and during retrieval the old one's score may be higher and rank first. Fix: by doc_id, delete the old chunks before loading the new ones (upsert semantics), not append.
- The source document did not change, but the ingestion log shows this doc was skipped -> the dedup logic misjudged "unchanged" (a wrong hash, or it compared the filename rather than the content). Fix: dedup by content hash, not by filename or modification time.
One scenario I postmortemed (built from a typical production pattern): an operations knowledge base where a document updated an alert threshold, and the RAG still answered with the old threshold. Checking the chunk for that document in the vector store, updated_at was two weeks old while the source document was from yesterday. The root cause was that the incremental ingestion's trigger condition was "a new file appeared," and a document "being modified" did not trigger a recompute — it treated "the document changed" as "this file was already processed long ago, skip it." Worse, the recompute logic was append rather than upsert, so even when it did trigger, old and new chunks coexisted. Fix: (1) change the trigger condition to "recompute on any content-hash change"; (2) on recompute, delete the old chunks by doc_id before loading the new ones. Lesson: incremental ingestion must "recognize content changes," not "recognize new files," and the recompute must "delete first, then load," or old and new chunks coexist and the old one keeps ranking first.
Layer 3: Chunk mapping broken — "the document changed, the chunking was not re-run / the old chunk holds the old slot"
Signature: FRESH, the chunks in the vector store look new, but the answer is still old. This is the most subtle layer, because "the vector store has data" and the problem lies in the "document to chunk to vector" correspondence being broken: the document changed but re-chunking was not triggered, so the old chunk still occupies its original vector slot.
# Take the latest content of the source document and grep for which chunk it maps to in the vector store, and whether that text is the latest
python3 - <<'PY'
import json, urllib.request, re
src = open('/data/kb/raw/device-42.md').read()
# Pull a sentence from the source that is "already changed" (a sentence you confirmed by hand is new content)
probe = "new alert threshold"
pts = json.load(urllib.request.urlopen(
'http://localhost:6333/collections/kb_chunks/points?limit=200&with_payload=true'))
hits = [p for p in pts['result']['points'] if probe in p['payload'].get('text','')]
print('chunks containing the new content:', len(hits))
for p in hits[:5]:
print(p['payload'].get('updated_at'), '|', p['payload'].get('text','')[:50])
# If hits is empty -> the new content was not sliced into the store (Layer 2); if hits exist but retrieval still hits an old chunk -> Layer 3
PY
Branching:
- The source's new content has no chunk at all in the vector store -> this is not Layer 3, it is Layer 2 (the new content was not sliced into the store); go back up one layer.
- The new chunk is in the store, but retrieval still hits the old chunk (both coexist, the old one first) -> the chunk mapping did not "delete old, keep new"; the old and new chunks are both retrievable. Fix: during retrieval, by doc_id, take only the latest version (or ingestion already deleted the old one first); do not let both enter the top-K.
- The document's structure changed (sections rearranged) but the old chunk's doc_id / section anchor was not updated -> the mapping metadata broke; the chunk still belongs to the old attribution. Fix: when re-chunking, also update the chunk's metadata (doc_id, section, timestamp); do not just swap the text.
One scenario I postmortemed (built from a typical production pattern): a knowledge base that rewrote the entire third section of a "fault-handling procedure" document (the steps went from 5 to 7), and the RAG still answered with 5 steps. In the vector store the new 7-step chunk was present, but the old 5-step chunk was also present — because "rewrite" was treated by ingestion as "append new content," and the old chunk was not deleted. During retrieval both the 5-step and the 7-step chunks entered the top-K, and the 5-step segment scored slightly higher, so the model preferred the old one. Fix: do "delete old, load new" by the document's section id, not a whole-document append. Lesson: a document "rewrite / rearrangement" must trigger "delete-then-load for that scope of chunks," or old and new coexist and the old one, scoring slightly higher, keeps jumping in to answer.
Generation layer: data is fresh, answer is old — "an old answer is hiding in the prompt"
Signature: FRESH, the whole top-K is new chunks, yet the answer is still old. If you have reached this layer, all three storage layers are fresh; the problem is in generation: the model's context carried something old.
# Print out the actual top-K chunk text returned for this retrieval and look for old content in it
grep -A3 "topk\|context" rag_app.log | tail -20
# Check the prompt assembly for any static old example / few-shot
grep -rn "few_shot\|example\|EXAMPLES\|system_prompt" rag_app/ 2>/dev/null
Branching:
- An old chunk slipped into the top-K (tied with the new one on score) -> this is not a pure generation problem, it is Layer 3's retrieval pulling the old one; go back up a layer.
- The whole top-K is new, but the system prompt has a hardcoded old answer / old example -> a generation-layer hardcode. The model was "led astray" to the old answer by the few-shot example. Fix: make the examples in the prompt follow the data version, or drop the static examples entirely.
- The whole top-K is new, the prompt has no old examples, and the model still answers old -> the model itself has a strong prior toward the old knowledge (in its training data this knowledge was old), and the current context did not override that prior. Fix: in the prompt, state explicitly that "the retrieved content below is the latest and takes precedence," raising the weight of the retrieved content.
A tradeoff worth stating: "data is fresh, answer is old" is the one most easily misdiagnosed as "a data problem," because every storage layer is fresh, and the troubleshooter instinctively suspects "did we not refresh it?" But refresh all the way down and every layer is fresh; the root is only in the generation layer — either the prompt carried an old example, or the model's prior is too strong. The way to localize it is "print the top-K text plus inspect the prompt assembly"; only when both are clean does it come down to "the model's prior," and the fix then is to re-weight, not to rebuild.
Three Failure Postmortems (built from typical production scenarios)
Case 1: Cache key did not carry the document version, so the document changed but the cache did not invalidate (Layer 1). An operator updated a device configuration document and the RAG still answered old. The provenance read source=CACHE — it had hit the query cache, the one computed last time. The root cause was that the cache key used only the query text and did not fold in the document version. Fix: append the document version to the cache key, and proactively invalidate on a document change. Lesson: cache invalidation needs a "proactive + version" double safety net, not TTL alone. The most expensive step was emitting the provenance log first; without it you flail on the wrong layer.
Case 2: Incremental ingestion picked up new documents only, append without deleting the old (Layer 2). A document updated an alert threshold and the RAG answered with the old threshold. The chunk's updated_at in the vector store was two weeks old; the source document was from yesterday. The root cause was that the ingestion trigger condition was "a new file appeared," a "document modified" did not trigger, and the recompute was append rather than upsert. Fix: (1) change the trigger to recompute on any content-hash change; (2) on recompute, delete the old chunks by doc_id before loading the new ones. Lesson: incremental ingestion must "recognize content changes," not "recognize new files," and the recompute must "delete first, then load," or old and new chunks coexist and the old one jumps in to answer.
Case 3: A document rewrite was treated as an append, so old and new chunks coexisted (Layer 3). The third section of a procedure document was rewritten from 5 steps to 7, and the RAG still answered with 5. The vector store held both the 7-step and the 5-step chunks — "rewrite" was treated by ingestion as "append new content," the old chunk was not deleted, and during retrieval the 5-step scored slightly higher and was picked first. Fix: delete-then-load by section id. Lesson: a document "rewrite / rearrangement" must trigger "delete-then-load for that scope," or old and new coexist and the old one, scoring slightly higher, keeps answering.
Closing: A Staleness-Check Checklist
All three layers plus the generation layer walked, and you cannot watch staleness by eye in production. My approach is to freeze "answer freshness" into a checklist that runs automatically after every document change:
# Freshness check after a document change (hooked on ingestion / the document-change hook)
def staleness_check(doc_id, golden_queries, src_mtime):
# Layer 1: cache — the related cache should be invalidated after a change
for q in golden_queries:
assert query_cache.get(semantic_key(q)) is None, f"cache not invalidated: {q}"
# Layer 2: vector store — the doc's chunk timestamps should be >= the source mtime, and the old chunks deleted
pts = fetch_doc_chunks(doc_id)
assert all(p['updated_at'] >= src_mtime for p in pts), "chunk older than source"
assert chunk_count(doc_id) == expected_chunk_count(doc_id), "stale chunks remain"
# Layer 3: mapping — the source's new content should grep-able to a matching chunk
probe = latest_probe_sentence(doc_id)
assert any(probe in p['text'] for p in pts), "new content not chunked"
# Generation layer: the golden queries' answers should hit the new content
for q, expected in zip(golden_queries, golden_answers):
assert expected in answer_with_provenance(q), f"stale answer for {q}"
return "fresh"
If any assert fails, raise an alert and indicate which of Layer 1 / 2 / 3 / generation it is stuck at. This checklist moves "stale answer" from "investigate after a user complaint" to "check immediately after a change"; the cost is running a few dozen assertions per change (seconds), far cheaper than shipping a stale answer, getting user complaints, and then going back to troubleshoot layer by layer.
The final independent judgment: the order for triaging a stale answer is "first establish the provenance (cache or fresh), then walk the layers down (cache to vector store to chunk mapping to generation layer), and only then consider a rebuild." Because the provenance and each layer's timestamp / grep are deterministic (they will not lie), while "rebuild the whole index" is the most expensive action. Putting the deterministic localization first and the expensive rebuild last is what drops the cost of "one blind rebuild" to "one correct layer refresh" — most of the time you only need to clear one cache layer or delete a batch of old chunks, not rebuild at all.
Related Articles
- When RAG Retrieval Returns Nothing — the companion piece: layer-by-layer triage when retrieval "returns nothing at all," complementing this piece's "something came back but it is old"
- Building and Operating a RAG Knowledge Base — the ingestion pipeline and how to build the chunk mapping; the upstream of the three layers in this piece
- When Retrieval Quality Suddenly Drops: An Embedding Index Drift Decision Tree — the companion piece: the "sudden quality drop" caused by swapping the embedding model, with a different mechanism from this piece's "content gone stale"
- Automated RAG Quality Evaluation — how to build the golden query set and how to check answer freshness automatically; the data foundation for the checklist in this piece
Originality statement: All provenance logs, staleness-check scripts, the decision tree, and the cases in this article are organized by the author from hands-on RAG operations. Cases are built from typical production scenarios and contain no real company names, IP addresses, or specific timelines.