Technical Guide

PII Detection Placement in the LLM Request Path

Detect PII at more than one point in the request path. Use a central enforcement point, such as a gateway, for prompts, responses, and tool calls.

Where PII enters and leaves a request

An LLM request passes through several stages, and PII can be present at any of them. Placement decisions start with knowing what moves through each stage.

Stages of an LLM request path
StageWhat passes through
User inputPrompts and attachments entering the system
RetrievalPassages pulled from connected data sources
Model inferenceAssembled prompt in, generated output back
Tool callsArguments sent to tools and results returned
Response deliveryOutput returned to the user or calling agent
Logging and telemetryTraces and records of every stage above

Placement options compared

Detection can sit at a central enforcement point, at retrieval and logging boundaries, or inside the application. Each placement covers a different part of the request path.

Detection placements and the stages they cover
PlacementWhere it appliesRole in the approach
Central enforcement point (for example, a gateway)Prompts, responses, and tool callsPrimary control, applying policy consistently from one point
Retrieval boundaryPassages pulled from connected data sourcesAdditional check before retrieved content reaches the model
Logging boundaryTraces and records of every stageAdditional check on what is stored
Application levelContext-specific needs within a given applicationSupplementary checks kept for specific cases

Reading the tradeoffs

No single placement covers every stage, so compare options against the criteria below.

  • Coverage: check whether prompts, responses, retrieved content, tool-call arguments and results, and logs or traces are all inspected, not only a subset.
  • Latency: document the added latency at each placement and how it was measured.
  • Accuracy: measure, tune, and review false positives and false negatives.
  • Context: use request context such as user, application, or agent identity in policy decisions.
  • Consistency: apply policy from one control point, with application-level checks reserved for context-specific needs.

Choosing an enforcement action

Choose the action per data type and stage, and configure it by policy rather than applying one action everywhere.

  • Block: stop the request or response that contains the detected PII.
  • Redact or mask: remove or obscure the detected value and let the rest continue.
  • Tokenize: replace the detected value with a token.
  • Allow with logging: let the content pass and record the decision.

Whichever action applies, record each decision as audit evidence without storing raw PII.

A layered placement approach

Combine placements so that each layer covers what the others cannot.

  1. Central enforcement point: inspect prompts, responses, and tool calls at a gateway or similar control point.
  2. Retrieval and logging boundaries: add checks where retrieved passages enter the request and where traces and records are written.
  3. Application level: keep checks here for context-specific needs.
  4. Action per stage: select block, redact, tokenize, or allow with logging for each data type and stage.
  5. Audit evidence: record every decision.

Requirements to evaluate in a gateway or runtime enforcement solution

  • Inspects prompts, responses, retrieved content, tool-call arguments and results, and logs or traces, not only a subset
  • Supports block, redact, mask, tokenize, and allow with logging, configurable by policy, data type, and stage
  • Documents added latency at each placement and how it was measured
  • Provides a way to measure, tune, and review false positives and false negatives
  • Uses request context such as user, application, or agent identity in policy decisions
  • Applies policy consistently from one control point and produces audit evidence for each decision without storing raw PII

Define your PII placement and enforcement model

Discuss how central runtime policy enforcement and audit logging can fit your LLM and agent architecture.

Talk to an Expert