ADR-002: Apply PII filtering to agent input and output
Chat agents use Presidio middleware to analyze and anonymize sensitive text, and privacy-processing failures are not bypassed.
1. Context & Problem
Customer conversations can contain personally identifiable information (PII). Sending unfiltered customer text to an AI model—or returning unfiltered model output to a caller—risks exposing sensitive values beyond the intended processing boundary.
Filtering only incoming requests would still leave sensitive content generated in responses unprotected, while filtering only final answers would still send the original unredacted input to the AI model. BookWorm needed a consistent, bidirectional privacy boundary applied across all conversational assistants.
2. Business Value
- Bidirectional data protection: Screens and anonymizes personal information both before text reaches an AI model and before replies return to the customer.
- Uniform enforcement across all assistants: Ensures primary specialists and delegated research assistants all follow the same application-level privacy control without relying on prompt instructions alone.
- Fail-safe privacy posture: Guarantees that privacy screening is never silently skipped if the privacy service experiences an outage or configuration error.
3. How It Works
- Universal coverage: All five Chat assistants—primary specialists and delegated researchers alike—route every non-empty interaction through a shared privacy screening step.
- Analyze and anonymize: Before text goes to an AI model, and again before generated output is returned, the screening step analyzes the text for personal information and anonymizes any sensitive values found.
- Hold streamed replies until checked: When an assistant generates a streamed reply, the output is held until privacy screening finishes, then released together.
- Fail closed on errors: If privacy screening fails for any reason, the request is stopped rather than allowing unfiltered text through.
4. Trade-offs & Lessons Learned
- Privacy assurance vs. availability (Fail-closed): Because requests stop when privacy processing fails, the availability and proper configuration of the privacy service directly govern whether chat requests can complete. Failing open would preserve uptime during an outage, but would defeat the privacy boundary precisely when its dependency is unhealthy.
- Bidirectional filtering vs. latency and streaming: Screening both inputs and outputs adds processing calls, and holding streamed responses until output screening finishes delays delivery to the caller.
- Defense in depth, not a silver bullet: Automated detection and anonymization cannot guarantee that every sensitive value is recognized or that transformed text can never be reidentified; callers and agents must still practice data minimization.
- Delegated assistant discipline: Future or modified delegated researchers must continue using the shared wrapped client path so subagent model calls never bypass input and output filtering.
Alternatives Considered
- Fail open when privacy processing is unavailable: Preserves response availability during an outage, but exposes unfiltered input to the model or unfiltered output to the caller.
- Filter only input or only output: Leaves either the AI model or the caller exposed to unprotected sensitive text.
- Rely only on agent instructions: Prompt guidance cannot enforce a consistent application-level processing boundary across registered assistants.
5. Technical Reference
- Decision status:
accepted(2026-11-04) - Coverage: All five Chat agents use the shared PII middleware, either registered directly or through the Book Agent’s wrapped client inherited by its delegated researchers.
- Privacy service integration: For non-empty text, the middleware calls Presidio APIServicev1.0.0Presidio APIExternal HTTP sidecar API for detecting PII in text and anonymizing detected entities in the Chat and Rating AI agent pi...SubscribesAnalyzeText, AnonymizeText +3APIsOpenAPIOwnerplatform-engineering-teamDiagramOpen docs in Data PrivacySystemv1.0.0Data PrivacyExternal Presidio system that detects and anonymizes personally identifiable information in the Reviews feedback-summari...Ownerplatform-engineering-teamDiagramOpen docs to analyze content via Analyze textCommandv1.0.0Analyze textDetects PII entities in one text string or a batch, returning entity types, text offsets, confidence scores, and optiona...Ownerplatform-engineering-teamSchemaDiagramOpen docs and, when PII is detected, anonymize it via Anonymize textCommandv1.0.0Anonymize textReplaces or transforms detected PII in text using the supplied analysis results and configured anonymization operators.Ownerplatform-engineering-teamSchemaDiagramOpen docs.
- Execution behavior: Applies symmetrically to model input and output; streaming output is buffered until output filtering completes, then emitted; failures propagate (fail-closed) rather than bypassing privacy processing.
- Scope note: Governs the shared model-call middleware; does not imply 100% detection recall or irreversibility of anonymized text.