PII Restoration
Restore reversible PII tokens in LLM responses back to their original values.
PII Restoration is the POST-stage counterpart to PII Tokenization. It reads token mappings from Redis and replaces all [PII_<ENTITY_TYPE>_<HASH>] tokens found in the LLM response with their corresponding real values.
This module has no configuration — it operates automatically based on the token map written by PII Tokenization for the same request.
Requires PII Tokenization
PII Restoration only works when PII Tokenization is attached to the PRE stage of the same deployment. Without it, there is no token map to restore from.
Stage
| Stage | Behavior |
|---|---|
| POST only | Reads Redis token mappings for the current request and replaces all [PII_<ENTITY_TYPE>_<HASH>] tokens in the LLM response with their original values |
Configuration
This module has no configuration parameters. Its behavior is fully determined by the token map created by PII Tokenization for the same request.
Lifecycle
PRE Stage → PII Tokenization writes token map & value keys to Redis (with TTL)
LLM processes anonymized request (using deterministic, cache-stable tokens)
POST Stage → PII Restoration reads Redis mappings and restores real values in the responseToken mappings are retained in Redis for the duration of the configured TTL window (default: 300 seconds), allowing multi-turn agent tool execution loops and follow-up turns to seamlessly restore the same tokens across multiple round-trips.
Failure Behavior
If the token map has expired (TTL elapsed) or is missing, PII Restoration will pass the LLM response through unchanged. Your client will receive the raw LLM output, which may contain [PII_<ID>] placeholders instead of real values.
To prevent this, ensure the Token Map TTL configured in PII Tokenization is set to a value that safely exceeds the maximum expected LLM response time for your deployment.
Example Use Cases
- Restoring personalized LLM responses: After tokenizing user data before an LLM call, automatically restore the real values so the response reads naturally for the end user.
- Round-trip PII protection: Together with PII Tokenization, creates a complete shield around the LLM call — PII never touches the provider, but the response remains fully meaningful.