LangGraph Memory Store and PHI: Retention and Cross-Patient Isolation for Health Plan Agents
The LangGraph memory store persists long-term memory as namespaced key-value items that outlive a single conversation. It gives you structure, not authorization. When items contain PHI, retention, deletion, member isolation, write-time redaction and audit evidence must be designed and enforced by you, ideally with runtime policy in the execution path on every read, write and tool call.
Design and enforcement checklist for PHI in agent memory
- Namespace scoping: build the namespace from an identity verified outside the model, such as the authenticated session, and include the member in every namespace and key. Never accept the identifier from prompts or tool arguments.
- Search containment: constrain every search to the member's namespace and reject any query that omits or widens the scope.
- Retention and deletion: assign a retention period to each record type, remove expired items on a schedule, and document how deletion reaches the backing storage and media.
- Redaction before write: inspect content before it is persisted, store only what the task needs, and redact or block everything else, in line with Privacy Rule limits on uses and disclosures.
- Access decisions at read time: evaluate entitlement on each retrieval, not only at session start.
- Audit-ready evidence: record every memory read and write with actor, member scope, action and decision.
How the memory store persists and retrieves data
In a LangGraph agent, short-lived conversational state belongs to a thread. Long-term memory is different. The memory store holds items as key-value records grouped under namespaces, and those items remain available to later threads and sessions. A namespace is a path-like grouping, a key identifies an item within it, and the value is the stored content. Agents retrieve items by key or by search across a namespace, and the data lives in whichever persistence backend the deployment uses.
For a health plan, this is the point at which an agent stops being stateless. A member's plan questions, claim details or care-related preferences written in one session can be retrieved in another. That is the useful behavior, and it is also the reason the store falls within the HIPAA Security Rule, which sets national standards for protecting ePHI that a covered entity or business associate creates, receives, uses or maintains. Memory that holds member information is maintained ePHI on a plain reading of that scope.
Where retention and isolation gaps arise
Application code rarely fails in dramatic ways here. The gaps tend to be quiet design choices that look reasonable in a prototype.
- Records that outlive their retention period: Items persist until something removes them. If no expiry or deletion process is attached to each record and its backing storage, PHI accumulates well past its permitted purpose.
- Namespace or key design that crosses members: A shared namespace, a key that is not member-specific, or a search that spans more than one member's items can surface one member's data in another member's session.
- Identifiers derived from untrusted input: If the member identifier used to build a namespace comes from the prompt, a tool argument or any value the user can influence, the isolation boundary is only as strong as that input.
- Unchecked writes: Agents can write whatever the model decides is worth remembering. Without inspection, free-text PHI, and sensitive details unrelated to the task, end up in durable storage.
What the store primitives cover and what remains yours
Namespaces and keys are an organizing structure. They make it possible to separate data by member, but nothing about a namespace establishes that the caller is entitled to read it. That decision depends on which identity was used to build the namespace and whether that identity was validated. OWASP describes this failure class as insufficient access validation, where an agent processes sensitive data beyond the user's authorization. Cross-member memory leakage is a specific instance of it.
Retention follows the same logic. Whatever expiry features a store version or backend offers, the Security Rule at Part 164 includes a required disposal specification: policies and procedures for the final disposition of ePHI and the hardware or electronic media holding it. Whether that provision applies directly to agent memory items is an interpretation to settle with counsel, but the design consequence is clear. Each record needs a defined lifetime, and deletion has to reach the backing storage, not only the application view.
Backend choice matters too. HHS lists a cloud service provider that stores ePHI on behalf of a covered entity or business associate as an example of a business associate. A hosted memory backend holding member data therefore raises a business associate question, while a self-managed backend in your own cloud changes the shape of that question. A January 2025 Federal Register document also proposed a network segmentation specification for the Security Rule. As of November 2026 it should be treated as a proposal and as directional only, not as a current requirement.
Where runtime policy enforcement fits
Application-level design sets the intended boundaries. Runtime enforcement checks that each interaction actually respects them. The two address different failure modes. Design prevents the namespace mistake from being written. Enforcement catches the case where a mistake, a changed prompt or an unexpected tool argument produces a request outside the boundary.
Trussed enforces policy in the execution path, so decisions are enforced at runtime, not reviewed after the fact. Where memory access passes through that path, for example as an agent tool call or a model interaction, policy can allow it, redact PHI from the content, block it, or escalate it for human approval. The scope is the individual interaction or tool call. A write containing free-text diagnosis details can be redacted before it is persisted. A read that targets another member's scope can be blocked. An unusual request can be routed to a person.
Trussed can be deployed self-managed in the customer cloud, with configurable retention and data residency, so enforcement and evidence can stay inside the same boundary as the memory data. It runs in production with healthcare and pharma organizations, and it does not replace the namespace design and deletion procedures described above.
Audit evidence and how to evaluate enforcement
A HIPAA audit-controls review under 164.312(b) looks for evidence that activity in systems holding ePHI can be recorded and examined. For agent memory, a reviewer needs to confirm two things: what the agent was permitted to do, and what it did with PHI. Evidence that shows only the outcome is weaker than a record that shows the policy applied and the decision made.
A useful memory event record contains the acting identity or agent, the member scope involved, the operation (read, write, search or delete), the namespace and key, the policy that applied, the decision taken (allow, redact, block or escalate), a timestamp, and a reference to any human approval. Trussed generates audit-ready evidence as a by-product of enforcement, mapped to HIPAA.
When assessing any enforcement approach, apply these criteria.
- Does it run in the execution path, so decisions are made before data moves rather than reconstructed later?
- Can it allow, redact, block or escalate individual memory interactions and tool calls?
- Does it hold up when identifiers originate from untrusted input?
- Is the evidence durable, attributable to an actor and member scope, and mapped to HIPAA?
- Can it run in your cloud, with retention and data residency you configure?
- Does it create a business associate relationship you must manage?
PHI risk points in agent long-term memory
Namespace
Derive the member scope from verified identity, never from model or user input.
Write
Check and redact content before it is persisted.
Read
Make an access decision on every retrieval, including search.
Retention
Assign an expiry and a disposal procedure to every record.
Evidence
Record who or what acted, on whose data, and what was decided.
Review your agent memory design against these controls
Talk to an expert about enforcing policy on memory reads, writes and tool calls in the execution path, and about the evidence a 164.312(b) review expects.
Talk to an ExpertHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.