Implementation Guide | Healthcare

    Keeping PHI Out of a LlamaIndex Retrieval Pipeline

    Preventing PHI exposure in a LlamaIndex pipeline takes two layers. De-identify and filter content at ingestion, then enforce policy at runtime on user queries, retrieved nodes, prompts, responses and tool calls. Ingestion scrubbing is necessary but incomplete, because PHI also arrives through queries and can survive de-identification. Runtime enforcement should decide allow, redact or block in the execution path and produce per-interaction evidence for audit controls under 164.312(b).

    Map the pipeline as five stages, each with its own PHI risk

    1. 1

      Ingestion

      Source documents and chunk text may contain identifiers. Chunking can also split an identifier from the context that would have flagged it.

    2. 2

      Indexing

      PHI persists in chunk text, embeddings and node metadata such as file names, patient or encounter fields, and source paths.

    3. 3

      Retrieval

      The user query may itself contain PHI, and retrieved nodes may return PHI the requester should not see.

    4. 4

      Synthesis

      Retrieved context and the prompt go to a model, and the response can repeat or recombine PHI.

    5. 5

      Tool use

      Query engines and agents can send PHI in tool arguments to systems outside the pipeline.

    Criteria for evaluating a runtime enforcement layer

    • It acts before content reaches the model or a tool, rather than only recording what already happened.
    • It covers user queries, retrieved nodes, prompts, responses and tool calls, matching your PHI entry-point inventory.
    • It supports allow, redact and block outcomes, with escalation to a human for decisions policy cannot settle.
    • It produces per-interaction evidence of the policy applied and the outcome, mapped to your audit requests.
    • It can be deployed in your own cloud, with retention and data residency you configure.
    • It lets you test detection and policy outcomes on your own data, including missed PHI and over-redaction.

    Ingestion-time de-identification is necessary but not sufficient

    Removing identifiers before indexing is the right first control. It shrinks what the vector store holds and limits what a retrieval bug can leak. It also gives you a place to drop fields you never needed, which supports data minimization generally.

    It cannot be your only control. NIST describes de-identification as a collection of approaches, algorithms and tools with differing levels of effectiveness, not a single technique. HHS publishes its own guidance on methods for de-identifying PHI under the Privacy Rule. A scrubbing tool is not automatically a method that meets that guidance, so define what "de-identified" means for indexed content and test against it.

    The practical limits are easy to anticipate. Pattern matching works well on structured identifiers but misses free-text references. Statistical entity recognition is probabilistic and can miss names or dates in unfamiliar note formats. Model-based detection adds variability and its own data path. Unstructured clinical text mixes all of these, so plan for residual PHI to pass ingestion and decide separately what happens afterward. Measure miss rates and over-redaction on your own text before trusting any detector.

    Ingestion controls also cannot see anything that happens later. A user can paste a patient name into a question. A retrieved node can reach a requester who should not see it. A model can echo a value from context. None of these pass through the ingestion script.

    Enforce policy at query time and in the model path

    Runtime controls sit where content actually moves: on the incoming query, on each retrieved node before it joins the prompt, on the assembled prompt, on the response, and on every tool call. LlamaIndex exposes extension points such as node postprocessors, query transformations and callbacks, which are natural places to attach checks. Choose them by whether they can change or stop content, not only observe it. A callback that records an event after the fact cannot prevent the event.

    At each point, decide the outcome in advance. Allow when content is within policy for that requester and purpose. Redact when the content is useful without the identifying element, for example a clinical question that does not need a patient name. Block when the content should not reach the next stage at all, such as PHI headed to a model or tool that is outside your approved boundary. Escalate to a human when the decision is consequential and the policy cannot settle it automatically.

    There are tradeoffs. Redacting retrieved nodes can degrade answer quality if context is stripped too aggressively. Blocking is safer but adds friction. Checks in the request path add latency, so scope them to the stages where the risk justifies it. Write the policy per stage, test it on real queries, and record false positives as well as misses.

    The minimum necessary idea is a useful design lens even where you are not citing a specific provision. Retrieve and pass to the model only what the task requires, and keep identifiers out of prompts when they add nothing.

    What a HIPAA-oriented review will ask you to show

    Audit controls are addressed in 164.312(b), within the Security Rule's technical safeguards. For an AI retrieval pipeline, the practical question an auditor asks is which PHI-handling policies were applied to a given interaction, and what the system did as a result. Answering that is hard when controls are spread across ingestion scripts, application code and vendor settings, because each produces its own partial record.

    Aim for evidence that is generated per interaction and consistent across stages. For one query, you should be able to show the policy version that applied, which stages were evaluated, what was detected, and whether content was allowed, redacted, blocked or escalated. You should also be able to show who approved any escalated action. Keep retention and data residency for this evidence under your control, since the evidence itself can contain sensitive material.

    Also confirm which parties in the pipeline are covered entities or business associates, including model and vector store vendors. Separately, a Security Rule proposal to strengthen cybersecurity of electronic PHI was published in the Federal Register in January 2025. As of November 2026, design against the rule currently in force and treat proposed requirements as proposals.

    Where Trussed fits as the second layer

    Trussed is not a replacement for ingestion de-identification. It is the runtime layer that follows it. Trussed enforces policy in the execution path across models, agents, tools and MCP servers, with outcomes of allow, redact, block, rate limit or escalate for human approval. Its scope is individual interactions and tool calls, so it applies at the points where a LlamaIndex query engine or agent sends content to a model or calls a tool. It does not trace entire agentic workflows end to end.

    Enforcement generates audit-ready evidence continuously, mapped to HIPAA among other frameworks. That gives security teams one evidence trail per interaction instead of stitching records together from scripts, application code and vendor settings. 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.

    Whether or not you use it, hold any layer to the criteria above: enforced at runtime, not reviewed after the fact, and tested on your own clinical text.

    PHI exposure points in a LlamaIndex pipeline

    Ingestion

    Loaders and node parsing handle raw documents

    Indexing

    Chunks, embeddings and metadata persist in the vector store

    Retrieval

    Queries and retrieved nodes carry content toward the model

    Synthesis

    Prompts and responses cross the model boundary

    Tool use

    Query engines and agents call external systems

    Review your PHI enforcement points with us

    Walk through your LlamaIndex pipeline stage by stage and see how runtime policy enforcement and audit-ready evidence apply to each interaction and tool call.

    Request a Demo