Deleting a Patient's PHI from a LangChain Vector Store After a Restriction Request
To delete PHI from a LangChain vector store, tag every chunk at ingestion with a patient-linked key and a source document ID, resolve the request to a list of chunk IDs, delete through the vector store interface using IDs or a backend-supported metadata filter, then clear caches, replicas, backups and derived outputs. Verify that retrieval returns nothing for the patient and keep a durable record of the request, the action and the verification.
A deletion workflow for a LangChain vector store
- 1
1. Record the decision
Capture who received, approved and will execute the request, and the control chosen: delete, suppress or block.
- 2
2. Resolve scope
Map the patient key to source documents and chunk IDs through the manifest, then run a metadata query to find untracked chunks.
- 3
3. Freeze writes
Pause re-ingestion for the affected documents so deleted chunks are not recreated by a scheduled sync.
- 4
4. Delete
Call the vector store delete with the resolved IDs, or a backend-supported filter, and capture the response.
- 5
5. Sweep residual copies
Clear caches, replicas, derived outputs and source copies as decided in the request.
- 6
6. Verify and close
Run retrieval tests, store the results and close the request with a retained record.
What to retain as the deletion record
- Request ID, date received, and the decision to agree or decline
- Names or roles of the persons who approved and executed the action
- Control chosen (delete, suppress or block) and the reason for it
- Resolved scope: source documents, chunk IDs, indexes and stores touched
- Delete call timestamps, backend responses and counts of items removed
- Verification queries, results and the dates of any re-tests
What a restriction request does and does not require
Under 45 CFR 164.522, a covered entity must permit individuals to request restrictions on uses or disclosures of their PHI for treatment, payment and health care operations, and on certain disclosures to family members and others under 164.510(b). The entity is not required to agree. If it does agree, it must abide by the restriction, except in emergency circumstances when the information is needed for the individual's treatment. As of November 2026, the supplied regulatory text shows no amendment that removes or changes this right.
Two scoping points matter for engineers. First, an agreed restriction does not prevent uses or disclosures permitted or required under 164.502(a)(2)(ii), 164.510(a) or 164.512. Second, the right to amend under 164.526 is a separate right, and the text of 164.522 describes a right to request restrictions, not a right to deletion. Deletion from a vector store is therefore one possible control for honoring a restriction, not something 164.522 prescribes.
That is why the first step is a decision, not a delete call. The privacy officer, with legal input, should decide per request whether to delete, suppress or block retrieval. Nothing here is legal advice, and engineers should not infer the scope of a restriction on their own.
Tag documents at ingestion so deletion is possible
Deletion fails most often because nobody can say which chunks came from which patient. A splitter produces many chunks from one document, each embedded and stored separately, and the vector itself carries no readable identifier. The link has to be written at ingestion, as metadata on each LangChain Document, before the chunks reach the store.
Use an internal pseudonymous patient key rather than a name or other direct identifier, so the metadata does not create a second copy of the identifying data. Keep the mapping from that key to the real patient in a system that already has access controls. Enforce the metadata schema in the ingestion code and reject documents that lack it, because untagged chunks are the ones you will not find later.
Also write a manifest outside the vector store that records, for each source document, the chunk IDs generated, the ingestion run and the target index. Assign deterministic or explicitly recorded IDs when adding documents, so you can delete by ID without depending on metadata filtering.
- patient_key: Internal pseudonymous key linking the chunk to the patient.
- source_doc_id: Identifier of the originating record or file.
- chunk_id: Explicit ID assigned at add time and stored in the manifest.
- ingest_run_id: Batch or pipeline run that produced the chunk.
- index_name: Target index or collection, to cover multiple stores.
Residual copies that survive a successful delete call
A delete call that returns success removes entries from one index. It does not remove everything derived from the same PHI. Some backends mark data as deleted first and reclaim storage later through compaction or similar maintenance, so confirm when your deployment makes removed data unreachable and when storage is actually reclaimed. Replicas and snapshots may keep removed data until they are rebuilt or expire.
Beyond the index, inventory these locations: LLM response and embedding caches, retriever or application caches, the source documents and object storage the pipeline reads from, intermediate outputs such as parsed text, summaries and chunk files, evaluation sets built from production data, and any second vector store or keyword index fed by the same pipeline. Assign an owner to each.
HHS states that the Security Rule requires policies and procedures for the final disposition of electronic PHI and the media it is stored on, and for removing electronic PHI from media before re-use. Snapshots and replica storage fit that framing. Whether an embedding is itself PHI is a question for your privacy and legal staff. A conservative design treats chunks and embeddings derived from PHI as in scope.
Verify that removed content cannot be retrieved
Verification should test the behavior the patient cares about, not only the store's internal state. Start at the store: fetch each deleted ID directly and confirm nothing returns, and run the metadata filter for the patient key and confirm an empty result. Then test through the pipeline. Use similarity queries built from distinctive phrases in the removed documents, including paraphrases, and confirm the retriever returns no chunk that carries the patient key. Run the full chain with prompts that would previously have drawn on that content and inspect the retrieved context and the response.
Repeat the tests after caches are cleared and after replicas have caught up, since a first pass can succeed against a node that is not the one serving later traffic. Schedule a re-test after the next ingestion cycle to confirm the data did not return from a source that was not cleaned.
Verification is evidence of behavior at a point in time. It does not prove that no copy exists in a location outside your inventory, so keep the inventory current and say so in the record.
Limiting retrieval while deletion is incomplete
Deletion across replicas, backups and source systems can take time, and an agreed restriction applies from the moment the entity agrees. During that window a runtime control can reduce exposure. Policy enforced at runtime in the execution path can allow, redact or block a retrieval or tool call that would surface a restricted patient's PHI, so the content is not passed to the model or returned in a response while cleanup proceeds.
Trussed enforces policy in the execution path in this way and generates audit-ready evidence from enforcement, mapped to HIPAA including 164.312(b) audit controls. It runs in production with healthcare organizations. It does not delete data from the vector store, and it is not a substitute for the deletion workflow above. It supplies a runtime control and evidence of what was allowed, redacted or blocked during the interval.
Restriction request deletion path
Scope
Privacy officer decides whether to delete, suppress or block.
Resolve
Patient key maps to source documents and chunk IDs.
Delete
Vector store delete by ID or metadata filter.
Sweep
Caches, replicas, backups, source files, intermediate outputs.
Verify and record
Retrieval tests and a retained deletion record.
Restrict retrieval of PHI at runtime while deletion completes
See how policy enforced in the execution path can allow, redact or block retrieval of restricted PHI and produce audit-ready evidence for a regulated enterprise.
Request a DemoHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.