Engineering · · 4 min read
Why does an agent still quote a document after it was deleted?
Trace deletion across source IDs, chunks, embeddings, caches, and saved answers so removed content stops resurfacing.
A team removes an obsolete escalation guide. The agent quotes it the next morning, complete with a convincing excerpt. Opening the citation fails. The source is gone, but a copy of its text remains somewhere in the retrieval path.
Deleting a source document and deleting every derived representation are different operations. A public LangChain forum question about record management asks how to remove a document that remains in a vector store. The application question is which retained copies must stop informing answers.
Map the copies before deleting blindly#
A source yields extracted text, chunks, embeddings, summaries, cached search results, and saved agent answers. Each needs a stable link to the source identifier and version; without it, an operator removes the visible document and leaves its most persuasive paragraph searchable.
Rechunking changes chunk identifiers even when the document is unchanged, so a deletion routine that remembers only the latest chunk list misses chunks from earlier ingestion versions.
Pinecone documents deletion by identifiers and metadata filters. The source-to-derived-data mapping determines whether you can use those operations completely.
Follow one retired procedure#
Take an on-call guide, source ID G-17. Version one produced chunks G-17-a through G-17-d; a parser update later produced six differently named chunks. If ingestion added the new six without removing the old four, deleting the newest six leaves the original procedure available.
Repair starts with a source registry of all active derived items for G-17:
- Mark the source unavailable for future retrieval.
- Remove or invalidate its searchable derivatives.
- Query the exact phrase that previously returned it, and confirm it no longer does.
Run a broader semantic query too: removed guidance can survive in a generated summary whose identifier does not resemble the source. A summary retained as company knowledge needs its own review and provenance; a parent document's past existence does not keep it authoritative.
Reviewed memory needs revisable scope, and deletion propagation makes it an engineering requirement.
Distinguish deletion from access loss#
A document can be deleted for everyone, moved outside the connector's scope, or become inaccessible to one user. These look alike in a failed read but need different history and recovery.
Do not label every permission error a global deletion, which removes content other users can legitimately read, and do not keep serving cached text to a user who lost access.
| Observed event | Retrieval response | History treatment |
|---|---|---|
| Confirmed source deletion | Exclude derived content | Keep allowed removal metadata |
| Permission revoked for one user | Deny that user's retrieval | Keep other users' access |
| Source moved outside sync scope | Remove from that scope | Record the change |
| Temporary provider failure | Mark availability gap | Do not invent a deletion |
| Procedure superseded | Prefer approved replacement | Retain old version for historical use only |
Close the cache path#
A perfect vector deletion fails if a query cache still returns the old excerpt. Include source versions or an invalidation generation in cache entries, and make every hit respect current identity and availability policy.
For saved answers, decide what the product promises. An old conversation can stay as history while its content is barred from reuse as current guidance. If retention policy requires removing the history too, make that a separate operation with its own scope.
A dead citation can mean "temporarily unavailable" or "retired." Return a structured unavailable or superseded status and, where permitted, a reference to the replacement, so the agent can explain why it cannot rely on the old passage.
Prove removal at the answer boundary#
Test the complete path: ingest a source, ask a question that needs it, remove the source, process the deletion, and ask again under the same identity. Assert that the old excerpt cannot return through direct search, cached search, or a retained summary.
Also test a permission revocation and a temporary outage so the connector does not mistake them for deletion, and record how long propagation takes and what the agent does meanwhile.
Fix the source mapping once for every consuming agent; start with connection setup for the affected source and evidence history for the retrieval path. Then save a test that keeps the guide retired.