AIF-48Required
Keep prompt and answer text briefly and apart
Store the text of prompts and answers apart from other logs, with personal data masked and access limited to named people. Delete it automatically after a set time, such as 30 days.
How to do it
Prompts hold what users typed, which often includes names, health details and other people's data. Mask known patterns, such as email addresses, phone numbers and card numbers, before storing. Keep the text in its own table or bucket, keyed by call ID, with a deletion job. Grant read access to named people only, never to a group or a shared account. Keep evals and reported cases longer only after removing personal data. Name the retention time in the privacy policy, and delete a user's stored prompts when they ask. The methods are in delete old data automatically and keep personal data out of logs.
Examples
SQL example
SELECT min(created_at) > now() - interval '30 days' AS within_limit FROM ai_call_text;
-- PASS when within_limit is true
TypeScript example
const EMAIL = /[\w.+-]+@[\w-]+\.[\w.]+/g;
const PHONE = /\+?\d[\d\s-]{7,}\d/g;
export const maskPersonalData = (text: string) => text.replace(EMAIL, '[email]').replace(PHONE, '[phone]');
await db.aiCallText.insert({ callId, prompt: maskPersonalData(promptText), answer: maskPersonalData(answerText) });
Python example
EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+")
PHONE = re.compile(r"\+?\d[\d\s-]{7,}\d")
def mask_personal_data(text: str) -> str:
return PHONE.sub("[phone]", EMAIL.sub("[email]", text))
db.ai_call_text.insert(call_id=call_id, prompt=mask_personal_data(prompt_text), answer=mask_personal_data(answer_text))
How to check
The oldest row in the prompt text store is younger than the set limit. A search of it for a test user's email address finds only masked values. The access list holds only named people, with no group or shared account.
Sources
Related rules
- DAT-31 Delete old data automatically in Data and databases
- OPS-9 Keep personal data out of logs in Operations and observability
- AIF-54 Record every step of every run in AI features
- AIF-65 Delete recordings once they are transcribed in AI features
- STK-111 Trace model calls with OpenTelemetry and read them in Langfuse in Software choices
- SUP-5 Delete closed tickets on a schedule in Customer support
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-features/logs-privacy-and-feedback/prompt-text-retention">Agent Wranglers AI features playbook</a>. In code you write, add a comment next to it with the same link.