Implementation Guide

Applying HIPAA Safe Harbor De-identification to LLM Prompts in Real Time

Safe Harbor (45 CFR 164.514(b)(2)) requires removing 18 specified identifier categories and having no actual knowledge that the remaining data could identify an individual. For LLM traffic, treat it as a testable specification enforced at a single runtime point that inspects prompts, retrieved context, and tool-call payloads.

What Safe Harbor requires for LLM prompts

Safe Harbor sets two conditions: remove the 18 specified identifier categories, and have no actual knowledge that the remaining data could identify an individual.

For LLM traffic, these conditions apply to prompts, retrieved context, and tool-call payloads. Treating the rule as a testable specification, enforced at a single runtime point that inspects all three, gives security engineers one place to define, verify, and evidence compliance.

Detecting and transforming identifiers

Detect with layered methods rather than a single technique. The pipeline combines:

  • Pattern matching
  • Entity recognition
  • Context rules

Each detected span is tagged by identifier type. Policy then determines how each identifier is transformed:

  • Suppression
  • Generalization
  • Tokenization

Ambiguous cases, failures, and re-identification

Policy decisions to allow, modify, or block a request are based on detector confidence, destination, and data type. When a detector times out, errors, or returns a result the policy cannot evaluate, the request is blocked.

The same applies on the return path. Model output is inspected for identifiers, and the pipeline decides whether re-identification is permitted before the response reaches users or tools.

Designing the enforcement point

Enforce at a point that every LLM call must pass through. A client-side library is easy to bypass. A gateway or proxy gives one place to apply policy, but it sees only what applications send to it. Agent runtimes and tool-call layers create additional paths that need the same inspection.

Runtime de-identification pipeline

Pipeline stages and what each one does
StagePurposeImplementation detail
1. InterceptCapture prompts, retrieved context, and tool payloads before they leave your boundary.Normalize encodings and extract text from every payload field, including nested JSON and tool arguments.
2. DetectCombine pattern matching, entity recognition, and context rules.Tag spans by identifier type.
3. TransformSuppress, generalize, or tokenize each identifier.Apply the action that policy specifies for each tagged span.
4. DecideAllow, modify, or block based on policy and detector state.Base the decision on detector confidence, destination, and data type.
5. LogRecord decisions as audit evidence without storing raw PHI.Write the decision, identifier types found, and policy version, not the raw text.
6. Handle responseInspect model output and decide whether re-identification is permitted.Inspect model output for identifiers and apply the same pipeline before it reaches users or tools.

Evidence, testing, and fail-closed behavior

  • Log each decision with timestamp, request and agent identity, destination, identifier types detected, action taken, and policy version.
  • Keep raw PHI out of logs. Store type and position metadata or hashed references instead.
  • Build a labeled test corpus of realistic prompts, retrieved chunks, and tool outputs. Measure recall per identifier category, not only overall.
  • Run the corpus as a regression test whenever detectors, models, or policies change, and sample production traffic for human review.
  • Block the request when a detector times out, errors, or returns a result the policy cannot evaluate.
  • Define the exception path for blocked requests, including who can approve it and how the approval is recorded.

Put de-identification under runtime policy control

Trussed AI provides runtime governance, policy enforcement, and audit logging for enterprise AI agents. Talk to an expert about where these controls fit in your LLM request path.

Talk to an Expert