Skip to content

feat(pii): restore request-scoped pseudonyms - #11272

Open
localai-org-maint-bot wants to merge 1 commit into
masterfrom
bot/issue-9535-pii-replacement
Open

feat(pii): restore request-scoped pseudonyms#11272
localai-org-maint-bot wants to merge 1 commit into
masterfrom
bot/issue-9535-pii-replacement

Conversation

@localai-org-maint-bot

Copy link
Copy Markdown
Collaborator

Description

Closes #9535.

Adds opt-in pii.reverse_in_response handling to the existing detector-driven PII middleware. Masked request values become unique, deterministic pseudonyms within the request (EMAIL_001, EMAIL_002) and are restored if the backend returns them. Restoration works for normal JSON and SSE tokens split across response writes; substitution maps remain request-local and are never persisted.

The model config metadata and middleware documentation expose the new toggle. Existing irreversible [REDACTED:...] behavior remains the default.

Notes for Reviewers

  • go test ./core/services/routing/pii ./core/config/meta
  • go vet ./core/services/routing/pii ./core/config/meta
  • The full core/config suite reaches 433/434 specs; its pre-existing remote-config validation spec fails because raw.githubusercontent.com returns HTTP 403 in this runner.

Signed commits

  • Yes, I signed my commits.
  • Documentation updated (docs/content/) for user-facing changes, or not applicable

Replace masked request values with unique per-request tokens when response restoration is enabled, then restore them across JSON and SSE write boundaries. Document the opt-in model setting and expose it in config metadata.\n\nAssisted-by: Codex:gpt-5
@mudler
mudler requested a review from richiejp August 1, 2026 12:15
@richiejp

richiejp commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

I think the name could be better. Something like "reversible redactions" or there may be a common term in usage for this already.

In the docs I think we should note that doing this makes it easier for a third party to reverse the redactions as well.

@richiejp

richiejp commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

markers like EMAIL_001 are very likely to collide with other text in the model output like [REDACTED:EMAIL_001] or similar won't, although the model may choose to remove the REDACTED part. Wrapping the ID with a prefix and postfix should probably be config options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Optional per-model PII replacement middleware (regex-based, bijective)

2 participants