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.
| Stage | What passes through |
|---|---|
| User input | Prompts and attachments entering the system |
| Retrieval | Passages pulled from connected data sources |
| Model inference | Assembled prompt in, generated output back |
| Tool calls | Arguments sent to tools and results returned |
| Response delivery | Output returned to the user or calling agent |
| Logging and telemetry | Traces 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.
| Placement | Where it applies | Role in the approach |
|---|---|---|
| Central enforcement point (for example, a gateway) | Prompts, responses, and tool calls | Primary control, applying policy consistently from one point |
| Retrieval boundary | Passages pulled from connected data sources | Additional check before retrieved content reaches the model |
| Logging boundary | Traces and records of every stage | Additional check on what is stored |
| Application level | Context-specific needs within a given application | Supplementary 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.
- Central enforcement point: inspect prompts, responses, and tool calls at a gateway or similar control point.
- Retrieval and logging boundaries: add checks where retrieved passages enter the request and where traces and records are written.
- Application level: keep checks here for context-specific needs.
- Action per stage: select block, redact, tokenize, or allow with logging for each data type and stage.
- 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