Prompts and completions contain user data. How do you redact PII in traces without destroying your ability to debug?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Redact at ingestion, before persistence, not on read. Redaction on read means the raw data is already sitting in your trace store and every access control gap is now a breach. Once it is written, you own it.
Full worked answer
Redact at ingestion, before persistence, not on read. Redaction on read means the raw data is already sitting in your trace store and every access control gap is now a breach. Once it is written, you own it.
The naive version, replacing everything with [REDACTED], makes traces useless. A conversation where every name is [REDACTED] cannot be followed. The fix is pseudonymisation rather than deletion: detect the entity, then replace it with a stable token derived from a keyed HMAC of the value, so the same person becomes PERSON_a91f consistently across the trace. You can still follow "the user asked about PERSON_a91f's order, and the tool returned the wrong record", which is the debugging question, without ever storing the name. Preserving shape helps too: keep type, rough length and position, since "the model hallucinated a 16-digit number" is a finding.
Detection is layered because the two approaches fail differently. Deterministic patterns catch structured data cheaply and reliably: emails, card numbers with a Luhn check, national IDs. An NER pass catches names, addresses and free-text mentions that patterns never will, at the cost of latency and recall gaps. Run patterns inline and the model pass inline if you can afford it, or asynchronously against a sample if you cannot.
Then tier the storage. Redacted traces get long retention and broad access. Raw capture, if you need it at all, gets a short TTL of days not months, encryption, access logging and a break-glass process, and I would scope it to error traces only.
Two things people forget. Index traces by user ID so a deletion request is a delete-by-key rather than a full scan. And do not ship raw prompts to a third-party judge or eval vendor without checking the data agreement covers it.
What a good answer covers
- Redact at ingestion, before persistence, not on read
- Redaction on read means the raw data is already sitting in your trace store and every access control gap…
- The naive version, replacing everything with [REDACTED], makes traces useless
- A conversation where every name is [REDACTED] cannot be followed
- The fix is pseudonymisation rather than deletion
In the glossary: Judge (LLM-as-judge)
Interviewer follow-ups to expect
Your NER redactor misses ~5% of names. Is that acceptable?
How do you debug a failure whose root cause was the exact text you redacted?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep