A customer-support assistant that aggregates listings from an internal catalog, partner feeds, and an operations wiki has a hard constraint: after updating docs, stale RAG answers mean the searchable corpus or a downstream cache did not advance with the source. Short answer: trace one edited listing through ingestion, parsing, chunking, embedding, index visibility, retrieval, and answer generation; record an immutable version at every boundary; and stop at the first boundary whose observed version is older than the source version. Do not begin by tuning prompts or forcing a full reindex. Those actions can hide why reindex processing is not running while increasing latency and destroying useful evidence.
This distinction follows directly from the retrieval-augmented generation architecture: generation is conditioned on retrieved external memory. If retrieval returns an old passage, an articulate generator can produce an articulate old answer. The operational problem is therefore change propagation, with an audit trail, rather than a vague complaint about model memory.
Why are RAG answers stale after updating docs?
A write and a searchable read usually travel through different paths. The content system may acknowledge version 184 while the extractor still holds version 183, the chunker may have produced a new set of chunks without retiring the old set, or the index may have accepted a write that is not yet visible to the query path. A response cache can then preserve the obsolete result even after retrieval is correct. Each boundary can be healthy in isolation while the end-to-end answer remains stale.
Start with one probe document whose new value is unmistakable but non-sensitive, such as changing a support listing's escalation window from 48 hours to 36 hours. Record the source identifier, source version, content digest, ingestion event identifier, transformation revision, index generation, and retrieval timestamp. The numbers are diagnostic coordinates, not proof by themselves.
The most common identity error is subtler than a failed job: an upsert key derived from chunk text changes when the text changes, so the new chunk is inserted while the old chunk remains retrievable. The query then sees two plausible passages. Stable identity should come from source identity plus a deterministic chunk position or semantic section identity; content hashes belong in version and audit fields, not in the primary identity that controls replacement. Deletion needs the same discipline. If a source emits seven chunks before an edit and five afterward, a successful five-chunk upsert does not retire the other two.
Make the pipeline prove its watermarks
Treat each transition like a ledger posting: it needs an idempotency key, an input version, an output version, and a durable outcome. Exactly-once delivery is a poor assumption across queues and indexes; idempotent effects plus reconciliation provide a testable contract. Keep the original event, including failures, long enough to reconstruct why a version advanced or stalled, subject to the retention and access limits that apply to customer-support data. Auditability does not justify retaining unrestricted ticket text forever.
A compact status record can drive both debugging and reconciliation:
package freshness
import (
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
)
type Version struct {
SourceID string
SourceRevision string
TransformRev string
IndexGeneration string
ContentDigest string
}
type StageStore interface {
Load(ctx context.Context, sourceID string) (Version, error)
PutIfNewer(ctx context.Context, key string, v Version) (bool, error)
}
func Digest(body []byte) string {
sum := sha256.Sum256(body)
return hex.EncodeToString(sum[:])
}
func IdempotencyKey(v Version) string {
return fmt.Sprintf("%s:%s:%s", v.SourceID, v.SourceRevision, v.TransformRev)
}
PutIfNewer must compare source revisions according to the source system's documented ordering; lexical comparison is not safe unless that contract explicitly says it is. The stored status should distinguish accepted, transformed, indexed, query-visible, superseded, and failed states. A single processed=true flag collapses precisely the evidence needed during an incident.
Then run a reconciliation query: source versions on one side, query-visible versions on the other. Reconciliation should report missing versions, unexpected duplicates, and orphaned chunks. It must not silently repair first. Preserve the discrepancy, attach the repair action to the same source version, and make replay idempotent. This is the same reason a payment ledger separates an adjustment from the historical posting it corrects.
Isolate retrieval before blaming generation
Issue the production-equivalent retrieval request without asking the generator to answer, using the exact tenant, locale, authorization filter, query normalization, and index alias used in production. Inspect returned source IDs and versions. If version 183 appears, the defect is upstream of generation. If version 184 appears but the answer quotes 183, inspect the prompt assembly and caches.
No guesswork.
Cache keys require versions too. A key composed only of normalized question and tenant can remain valid across a document update. Include a corpus generation or a dependency token representing the retrieved source versions, and define invalidation as part of the publish transaction. Where immediate invalidation would add unacceptable write latency, expose a bounded freshness objective and measure it from source commit time to query visibility. Customer-support staff need to know whether a listing is authoritative now, not merely whether an indexing worker eventually logged success.
Filters deserve a separate check because they mimic staleness. The fresh chunk may exist but carry the wrong listing status, region, tenant, or effective-date metadata, leaving the retriever eligible to select only its predecessor. Compare metadata before and after transformation, and test authorization with the same principal as the stale answer. Never bypass access filters merely to make the fresh record rank.
Choose freshness without sacrificing retrieval quality
The quality-versus-latency decision is not binary. A full corpus rebuild offers a coherent snapshot but delays urgent listing changes and spends work on unchanged content. Its limitation is scale: it is not suitable when a support listing must become searchable before a large snapshot can finish. Incremental indexing shortens the path, yet it requires stable identifiers, tombstones, version comparisons, and reconciliation. A small exact-match overlay for recently changed listing identifiers can protect critical updates while the semantic index catches up, although it creates another state boundary that must be audited and expired. That trade-off is defensible only when the overlay has deterministic precedence and a bounded lifetime.
| Approach | Query effect | Freshness behavior | Operational obligation |
|---|---|---|---|
| Snapshot rebuild | One coherent generation | Changes wait for publication | Atomic alias switch and rollback record |
| Incremental upsert | No extra query branch | Fast when the event path is healthy | Idempotent keys, tombstones, reconciliation |
| Recent-change overlay | Adds a merge step | Critical records can appear sooner | Deterministic precedence and expiry |
Choose from measured service objectives. Track source-to-visible delay as a distribution, retrieval success for known changed listings, duplicate-version rate, dead-letter age, and reconciliation lag. Average indexing duration is insufficient: a fast median can coexist with one permanently stranded listing. Also cap the latency cost of freshness checks; synchronously querying every upstream source may yield current data but turn the assistant into a fragile fan-out service.
Evaluation needs temporal cases, not a static relevance set. For each test listing, retain a sequence of revisions and assert three properties: the current revision is eligible after its committed watermark, superseded text is ineligible, and an unchanged query still retrieves the best relevant passage. That last property prevents a freshness repair from degrading retrieval quality through overly aggressive deletion or crude recency boosting.
Debug in a fixed order
Use the probe's version trail to narrow the fault before changing configuration:
- Confirm the authoritative source exposes the expected revision and content digest.
- Find the corresponding ingestion event and verify that retries share one idempotency key.
- Compare extracted text and metadata with the source; record the transformation revision.
- Verify the complete new chunk set and the tombstones for chunks no longer present.
- Confirm the target index generation contains the expected version and that the production alias queries that generation.
- Retrieve with production filters, then inspect prompt assembly and version-aware caches.
- Reconcile all sources against query-visible state after repairing the single probe.
This order protects evidence and limits blast radius. A blind reindex may make the probe fresh while leaving the causative bug, duplicated old chunks, or a stale cache untouched. It also makes it harder to say which transition failed, an unacceptable outcome where support answers feed regulated workflows or contractual service decisions. Log identifiers and version metadata rather than unrestricted customer text, apply least-privilege access, and align retention with the organization's applicable compliance obligations. Specific limits depend on jurisdiction, data classification, and policy; the architecture cannot invent them.
Roll out the repair as a controlled migration
First, add version fields and visibility probes without changing ranking. Next, enable reconciliation in report-only mode and establish the true mismatch rate. Repair one source partition with idempotent replay, verify freshness and retrieval-quality tests, and then expand by partition while retaining an atomic rollback to the prior index generation.
Finally, alert on breached freshness objectives and stranded versions, not merely worker errors. A worker can report success while publishing to the wrong generation. The durable acceptance test is simple: the source revision committed, the same revision became query-visible under production filters, and superseded chunks became ineligible. That chain makes stale answers diagnosable without trading away the retrieval quality that made the assistant useful.
References
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks: https://arxiv.org/abs/2005.11401
Top comments (1)
The chunk identity point is the one I would put first. If the upsert key includes the content hash, every edit inserts a new chunk and the old one keeps matching queries, so you see the old and the new answer competing. Keying on source id plus section position, and storing the hash only as a version field, fixes that.
One extra check for the probe document: after the edit, query the index for the old value directly (for example the string 48 hours). If anything still returns it, you have an orphan chunk or a cache entry, and that tells you which boundary to inspect before you touch the embedding step.