How to Keep PHI Out of Google ADK Session State, Memory, and Artifacts
Treat session state, memory, and artifacts as separate persistence surfaces. For each one, identify how PHI can reach it (user prompts, tool responses, model outputs), redact or block before the write, limit scope and retention, and confirm the backing service sits inside your HIPAA control boundary. Framework-level controls are necessary but not sufficient. Policy enforced at runtime, in the execution path, adds allow, redact, or block decisions and produces the evidence that supports audit controls under 45 CFR 164.312(b).
Control checklist by persistence surface
- Inventory enabled surfaces, backing stores, and readers for every agent.
- Allow-list session state keys and redact or block PHI at the point of write.
- Ingest into memory only redacted content, partitioned per user, with a documented retention limit.
- Decide per artifact save whether it is permitted, and store permitted artifacts in-boundary with expiry.
- Define and document the inactivity period used for session expiry.
- Retain evidence of each allow, redact, and block decision for 164.312(b) review.
Why persistence is the exposure
The HIPAA Security Rule establishes national standards for protecting electronic PHI that a covered entity or its business associate creates, receives, uses, or maintains. An agent that writes PHI into a persistence layer is maintaining it, so that layer is in scope along with the model call that produced it. If your organization acts as a covered entity or business associate, every service that stores agent data needs to be inside your control boundary, with the contractual and technical coverage that implies.
Three entry paths matter. User prompts carry whatever people type. Tool responses carry whatever a connected system returns, often more fields than the task needs. Model outputs can repeat or recombine PHI from either. Once any of these is written to session state, memory, or an artifact store, the data can outlive the interaction, be read in a later session, or be reachable by a different user than the one it belongs to.
Start with an inventory: which of the three surfaces are enabled in each agent, which backing store each uses, who can read from it, and how long data stays. Every control below depends on that map being accurate.
Session state: scope it, sanitize it, and bound its lifetime
Session state is the easiest surface to pollute, because developers use it as a convenient scratch space. Values written during a turn, such as a patient name, a member ID, or a tool result, remain available to later steps and persist wherever the session is stored.
At design time, define an allow-list of keys that may be written to state and keep clinical content out of it. Store identifiers as opaque references where the agent only needs to refer to a record, and fetch the record again when needed. Apply redaction or blocking at the point of the write, not at read time, since a read-time filter leaves the stored value in place. Scope state per user so one person's values cannot surface in another person's session.
Session lifetime also connects to the Security Rule. The automatic logoff specification in 164.312 is addressable, not required, and calls for electronic procedures that end an electronic session after a predetermined period of inactivity. If you use session expiry to support it, define the inactivity period and document the decision.
At runtime, the question is whether a write that contains PHI is stopped. Test with synthetic patient data and confirm the stored value is redacted or the write is rejected.
Memory: the highest risk of reuse across sessions and users
Long-term memory is designed to carry information forward, which makes it the surface where an early mistake compounds. If PHI is ingested from a conversation, it can be recalled in a later session and shown to a different user or used for a purpose unrelated to the original one.
The safest default is to ingest only content that has already passed redaction, and to exclude whole categories of sessions from ingestion, such as any session that touched a clinical system. Prefer storing task-level facts, such as a user's preferred format or a resolved procedural answer, over transcripts. Partition memory by user or tenant, and set a retention limit that matches the purpose of the memory. Retention limits are a design decision you justify and document, not a figure this guide can prescribe.
Two patterns need their limits understood. De-identification before ingestion reduces exposure, but pattern-based detection misses free-text identifiers and context that identifies a person indirectly. Tokenization replaces values with surrogates, but the mapping table is then itself a store of PHI that needs the same protections. Neither removes the need to check what actually landed in memory.
Artifacts: files bypass text-oriented controls
Artifacts are files or binary objects an agent or tool saves, such as generated reports, exported records, uploaded documents, or images. They are often large, long-lived, and outside the text paths where redaction is usually applied. A summary of a chart can be redacted in a prompt while the exported PDF it came from is saved intact.
Treat each artifact save as a write that needs a decision. Block saves of documents that originate from clinical systems unless the workflow requires them. Where saving is necessary, store the object in a service that is inside your HIPAA control boundary, apply customer-managed encryption keys if your policy requires key control, restrict access by identity, and set an explicit expiry. Encryption protects stored data from outside access, but it does not reduce what is stored or who inside the system can retrieve it, so it complements minimization rather than replacing it.
Because content in files is harder to inspect, the most reliable control is often to prevent the PHI from reaching the file in the first place, by redacting the tool response or model output that feeds it.
Runtime enforcement and audit evidence
Framework-level controls such as state key allow-lists, scoping, and retention depend on every developer using them correctly in every agent. They are necessary, but they are design-time controls, and a single tool added later can route PHI around them. Enforcement in the execution path closes that gap by evaluating each interaction and tool call as it happens.
Trussed enforces policy in the execution path across models, agents, tools, and MCP servers. For each individual interaction or tool call, it can allow, redact, or block, so PHI in a prompt, tool response, or model output is handled before an agent step carries it toward a persistence write. Enforcement is at runtime, not reviewed after the fact. Its scope is individual interactions and tool calls. It complements, and does not replace, per-user scoping, retention limits, and backing-service configuration.
The same enforcement produces audit-ready evidence: a record of what was allowed, redacted, or blocked, and under which policy. That evidence is mapped to HIPAA, including the audit controls standard at 164.312(b), so a security team can show that controls operated rather than only that they were configured. Trussed can be deployed self-managed in the customer cloud, with configurable retention and data residency, and it runs in production with healthcare and pharma organizations.
One regulatory item to monitor: a proposed rule published in the Federal Register in January 2025 would require written policies and procedures for authorizing access to ePHI and relevant systems. It is a proposal, so do not treat it as binding as of November 2026.
PHI entry points and persistence surfaces
Entry: user prompts
Patients and staff paste identifiers and clinical detail into free text.
Entry: tool responses
EHR, scheduling, and claims lookups return records the agent did not request in full.
Entry: model outputs
Generated summaries restate PHI and can be written back as state.
Surface: session state
Working data kept for the duration of a conversation.
Surface: memory
Information retained for reuse beyond a single session.
Surface: artifacts
Files and documents saved by the agent or its tools.
Enforce PHI policy before data is persisted
Talk to our team about enforcing allow, redact, and block decisions on agent interactions and tool calls, and about the audit-ready evidence that results.
Explore Agent and Tool-Call EnforcementHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.