Home / Insights / AI Agents and Automation

AI Agents and Automation

Protecting Personal Data in AI Chats: PII Redaction, Retention and Logging Decisions

An AI chat feature copies personal data into more places than most teams realise: prompts, model provider logs, traces, vector stores and analytics. This guide shows a CTO how to decide what to redact, what to keep and for how long.

TopicsAI Agents and AutomationGenerative AI and LLMs

Key takeaways

  • Map every copy of a conversation first: client, application database, model provider, traces, analytics, vector store and evaluation sets. Most leaks happen in the copies nobody owns.
  • Redact in layers: deterministic patterns and checksums for structured identifiers, an entity recogniser for names and addresses, and pseudonymisation where the workflow needs the real value later.
  • Set retention per data type, not per system. Raw transcripts, redacted transcripts, traces and embeddings have different purposes and should have different clocks.
  • Logs are the biggest blind spot. Log metadata and redacted text by default, and make raw-content logging an exception with an expiry date.
  • Read your model provider’s data controls carefully: training defaults, abuse-monitoring retention and stateful features that store data until you delete it.

When a customer types their address, policy number or medical history into a chatbot, that text does not stay in one place. It travels to your application server, to a model provider, into your tracing tool, into an analytics warehouse and sometimes into a vector store or an evaluation spreadsheet. Each copy is a liability under data protection law and a target for attackers. Each copy also has a legitimate use, which is why simply deleting everything is rarely an option.

This article is for CTOs, engineering leads and product owners who are shipping or running an AI chat feature and need a defensible position on personal data. I will cover where personally identifiable information (PII) enters and leaks, how the main redaction techniques compare, how to set retention periods, how to log safely, which model provider settings matter, and a step-by-step plan to put it all in place. The examples assume a customer-facing assistant, but the same decisions apply to internal tools.

Where does personal data enter and leak in an AI chat system?

Before choosing tools, draw the data flow. In almost every review we run, the team knows about the chat database and the model call, and has forgotten at least two other copies.

The usual copies of a conversation

  1. Client and transport. Browser or app state, push notifications and any client-side analytics that capture typed text.
  2. Application database. Conversation history stored so users can continue a chat or staff can review it.
  3. Model provider. The prompt, retrieved context and response are sent to the model API and may be retained by the provider for a period, depending on its terms and the features you use.
  4. Retrieval context. Customer records, tickets or documents pulled in to answer a question. These often contain more personal data than the user typed.
  5. Tool calls. Order lookups, CRM updates and booking calls carry identifiers in their arguments and results.
  6. Traces and logs. Observability tools often capture full prompts and responses by default.
  7. Analytics and evaluation. Exports for dashboards, labelling, fine-tuning or regression tests.
  8. Vector stores. If you embed past conversations or tickets, personal data now lives inside an index that is hard to inspect.

How the leaks happen

The OWASP Top 10 for LLM Applications 2025 lists sensitive information disclosure as LLM02, with examples that include one user receiving another user’s personal data because of inadequate sanitisation, and attackers using prompt injection to bypass input filters. OWASP also warns that instructions in a system prompt restricting what data may be returned can be bypassed, so they must not be the only control. In practice, the most common incidents we see are less dramatic: a support engineer pastes a raw trace into a ticket, or an analytics export lands in a shared drive with no expiry.

Write the map down as a table with one row per copy, an owner, a purpose and a current retention period. That table becomes your design document and, later, part of your data protection impact assessment.

Which redaction techniques should you use, and where?

Redaction is not one technique. It is a set of detectors and transformations applied at different points in the flow. The right mix depends on the identifiers you handle and whether the workflow needs the real value later.

TechniqueGood atWeak atTypical place
Regular expressions and checksumsCard numbers, phone numbers, emails, national IDs, account numbers with known formatsNames, addresses, free-text health detailsInbound message, logs, exports
Named entity recognition (NER)Person names, locations, organisations in free textDomain-specific identifiers; languages it was not trained onInbound message, transcripts before storage
LLM-based detectionContext-dependent sensitive details, unusual formatsCost, latency, consistency; it is another model to evaluateOffline review of stored transcripts, edge cases
Pseudonymisation (token vault)Workflows that need the real value later, such as an order lookupAdds a secure mapping store you must protectBetween application and model provider
Masking or truncationShowing staff enough to verify (last four digits)Analysis that needs full valuesAgent interfaces, dashboards

Use an established toolkit as a base

Open-source tools save time. Microsoft’s Presidio, for example, separates an analyzer that detects PII from an anonymizer that de-identifies it, and combines named entity recognition, regular expressions, rule-based logic and checksums, with support for context cues and multiple languages. Its maintainers are explicit that there is no guarantee it will find all sensitive information, and recommend additional protections. Treat any detector the same way: as one layer with a measured miss rate, not as a guarantee.

Decide what the model actually needs

The best redaction is not collecting the data in the first place. Ask, field by field, whether the model needs it to produce a good answer. A returns assistant needs the order reference and items; it does not need the card number. Where the model needs to refer to something without seeing it, replace it with a stable placeholder such as [ORDER_1] and resolve it in your own code when calling the order API. This keeps business logic out of the model and personal data out of the provider’s logs.

Measure your detectors

Build a small labelled set of realistic messages in each language you support, with the identifiers marked. Measure recall (how many identifiers were caught) per entity type. A detector that catches 99% of emails and 70% of street addresses needs a different policy for addresses, such as stricter retention on transcripts that may contain them.

How long should you keep each type of chat data?

Data protection law does not set a single number of days for chat logs, but it does require you to justify what you keep. The GDPR’s recitals, published on EUR-Lex, say personal data should be limited to what is necessary, and that controllers should set time limits for erasure or periodic review so data is not kept longer than needed (Recital 39). They also note that pseudonymisation can reduce risks to data subjects (Recital 28). Similar principles appear in the UK GDPR, the Australian Privacy Principles and Vietnam’s Decree 13/2023 on personal data protection.

Set a clock per data type

Data typePurposeIllustrative retentionNotes
Raw transcript (unredacted)Dispute handling, user continuityShort, such as 30 daysRestrict access; consider not storing at all
Redacted transcriptQuality review, analyticsLonger, such as 12 monthsStill treat as personal data if re-identification is possible
Traces with contentDebugging specific incidentsDays, such as 7 to 14Default to metadata-only traces
Metadata (timestamps, intents, latency, cost)Monitoring and reportingAs long as usefulAvoid free-text fields
Evaluation setsRegression testingUntil replacedBuild from redacted or synthetic examples
Embeddings of conversationsSearch, similar-case retrievalMatch the source recordDelete vectors when the source is deleted

The periods above are illustrative starting points, not legal advice. Agree them with your data protection officer or counsel, record the reason for each, and make deletion automatic. A retention policy that relies on someone remembering to run a script is not a retention policy.

Handle deletion requests end to end

When a user asks for erasure, you need to find and delete their data in every copy on your map: database rows, trace stores, exports, vector indexes and any provider-side stored objects. Test this flow before launch with a dummy user. It is far easier to design a user identifier that propagates to every store than to retrofit one.

How do you log and observe an AI chat without leaking data?

AI systems are hard to debug without seeing prompts and responses, so engineers naturally want to log everything. That instinct creates the largest uncontrolled copy of personal data in most stacks.

Default to metadata, escalate to content

  • Always log: conversation and user identifiers (pseudonymous), timestamps, model and prompt version, token counts, latency, cost, tool names called, outcome (resolved, escalated, abandoned), guardrail decisions.
  • Log redacted content by default for quality review, using the same redaction pipeline as storage.
  • Log raw content only by exception, for a named incident, with time-boxed retention and an access record.

Protect the logging pipeline itself

  • Restrict who can view traces with content, and record access.
  • Configure your observability tool’s masking features before connecting production traffic, not after.
  • Keep production traces out of general-purpose channels such as chat tools and ticket attachments.
  • Scrub tool-call arguments and results, not just the user message. Order and CRM responses often contain addresses and phone numbers.

The NIST guide to protecting PII, SP 800-122, groups the relevant safeguards under control families such as access control, audit and accountability, and system and communications protection. It predates generative AI, but the structure maps well onto AI logging: decide who can access, record that they did, and protect the data in transit and at rest. For tracing design more broadly, see our guide to observability for AI agents in production.

Which model provider settings matter for personal data?

Your provider’s defaults are part of your data protection posture. Read the data usage documentation for each provider and feature you use, not only the marketing summary.

Questions to answer for each provider

  • Training: is API data used to train models by default? OpenAI, for example, states in its API data documentation that data sent to the API has not been used to train its models since 1 March 2023 unless the customer opts in.
  • Abuse monitoring retention: how long are prompts and outputs kept for safety review? The same documentation describes abuse-monitoring logs kept for up to 30 days by default, and a zero data retention option for approved customers.
  • Stateful features: which features store data until you delete it? Assistants, threads, files and vector stores are stored objects, whereas stateless completion calls are not stored in the same way. If you use stored objects, they belong on your retention map and your deletion flow.
  • Region: where is data processed and stored, and does that meet your contractual and regulatory commitments?
  • Contract: is there a data processing agreement, and does it list subprocessors?

Compare the options honestly

ApproachData exposureTrade-off
Public API, default settingsProvider retains for abuse monitoringSimplest; acceptable for many low-risk uses with redaction
Public API with zero retention or enterprise termsReduced provider retentionRequires approval or a higher tier; some features may be unavailable
Cloud-hosted model in your own cloud accountStays within your cloud tenancy and regionMore set-up; model choice depends on the cloud catalogue
Self-hosted open modelFully under your controlHighest operating effort; quality and security are your responsibility

For regulated health data in particular, our article on building HIPAA-compliant AI covers vendor agreements and hosting choices in more depth.

What does a practical implementation plan look like?

This is the sequence we follow when we add data protection controls to a chat assistant, whether new or already live.

  1. Map the data flow with one row per copy, owner, purpose and retention. Include tool calls and exports.
  2. Classify the data you expect: contact details, identifiers, financial data, health or other special categories. Special categories usually justify stricter handling.
  3. Minimise inputs: remove fields the model does not need, and replace identifiers with placeholders resolved in code.
  4. Add inbound redaction using pattern and checksum detectors plus an entity recogniser, tested on a labelled set in each supported language.
  5. Apply the same pipeline to storage and logs, and switch traces to metadata-only by default.
  6. Configure provider settings: training opt-outs, retention options, region and data processing agreements.
  7. Automate retention per data type, including vector stores and provider-side stored objects.
  8. Build and test the erasure flow across every store with a test user.
  9. Update the privacy notice so users know an AI system processes their messages and how long data is kept.
  10. Monitor and review detector recall, access logs and exceptions every quarter.

For example, a 30-person insurance broker adding a policy-question assistant might complete steps 1 to 6 in a few weeks before launch, and schedule 7 to 10 for the first month of operation. That timeline is illustrative; the point is that minimisation and logging defaults must be in place before real customers type into the box.

We applied the same principles in our clinical operations platform work for an Australian healthcare client, where AI referral processing and dictation features handle sensitive information and access and logging rules had to be designed in from the start. The same approach applies in our AI chatbot development work, where answers are grounded in approved content, sensitive topics are restricted, uncertain cases are escalated, and evaluation sets and monitoring are part of every AI feature.

What are the residual risks and costs, and what is the checklist?

Residual risks

  • Detector misses. No automated detector is complete. Compensate with short retention on content-bearing stores.
  • Re-identification. Redacted transcripts can still identify someone through context. Treat them as personal data.
  • Prompt injection. Attackers may try to extract data via the model. Enforce access in code: the model should only ever see records the current user is entitled to.
  • Shadow copies. Developers exporting samples for testing. Provide a safe, redacted sample set so they do not need to.

Costs to budget for

  • Engineering time to build the redaction pipeline and evaluation set.
  • Added latency and compute for detection on every message.
  • Security for the pseudonymisation vault, if you use one.
  • Ongoing review of detector performance and access logs.

Personal data checklist for an AI chat feature

  1. Data flow map completed, with an owner for every copy.
  2. Inputs minimised; identifiers replaced with placeholders where possible.
  3. Inbound redaction in place and measured per entity type and language.
  4. Traces default to metadata only; raw-content logging is time-boxed.
  5. Retention set per data type and enforced automatically.
  6. Provider training, retention and region settings confirmed in writing.
  7. Erasure tested across database, logs, exports, vectors and provider-side objects.
  8. Privacy notice updated to cover AI processing.
  9. Access to content-bearing stores restricted and recorded.

For the wider set of controls that sit alongside PII handling, such as topic restrictions and output checks, see our guide to guardrails for generative AI.

Frequently asked questions

Should we redact personal data before sending it to the model provider?

Where the model does not need the value, yes. Replace identifiers with placeholders and resolve them in your own code when calling business systems. Where the model needs the content, such as a description of a problem, rely on provider data controls, minimisation and short retention instead.

Is a redacted transcript still personal data?

Often it is. If someone can be identified from context, or if you hold a mapping that reverses pseudonymisation, treat it as personal data under GDPR-style laws. Redaction reduces risk; it does not remove your obligations.

How long should we keep AI chat transcripts?

There is no single legal number. Set a period per data type based on purpose, such as short retention for raw transcripts and longer for redacted ones used in quality review, record the reasoning, and automate deletion. Confirm the periods with your data protection adviser.

Do model providers train on our chat data?

It depends on the provider, product and settings. OpenAI, for example, states that API data has not been used for training since March 2023 unless you opt in, but keeps abuse-monitoring logs for up to 30 days by default. Check each provider’s current documentation and contract.

Can we use real conversations to build evaluation sets?

You can, but redact them first, limit access, and set a review date. Many teams combine redacted real examples with synthetic ones so the set reflects real behaviour without carrying unnecessary personal data.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. OWASP GenAI Security Project: LLM02:2025 Sensitive Information Disclosure — accessed 9 November 2026. Leak scenarios, sanitisation and access-control mitigations, and the warning that system prompt restrictions can be bypassed.
  2. Microsoft Presidio (GitHub repository) — accessed 9 November 2026. Analyzer and anonymizer design, detection methods, and the caveat that automated detection will not find all sensitive information.
  3. EUR-Lex: Regulation (EU) 2016/679 (GDPR), consolidated text — accessed 9 November 2026. Recital 39 on limiting data and setting erasure or review time limits; Recital 28 on pseudonymisation reducing risk.
  4. NIST SP 800-122: Guide to Protecting the Confidentiality of PII (April 2010) — accessed 9 November 2026. Control families relevant to logging and access: access control, audit and accountability, system and communications protection.
  5. OpenAI API documentation: Data controls — accessed 9 November 2026. No training on API data since 1 March 2023 by default, abuse-monitoring logs up to 30 days, zero data retention, and stored objects such as threads and files.

Do you know every place your chatbot stores customer data?

We can review your AI chat data flow, redaction and retention settings and give you a prioritised list of fixes, with assumptions stated.