AI tools helped gather research and write the first draft of this article. I edited it and checked every quote and figure against the source page listed at the end, read on 2 December 2026. The cover illustration is AI-generated. Details at the end.
A user types a message into your AI chat. By the time the reply appears, that message may exist in five or six places: the prompt sent to the model provider, the provider's own records, your application log, a trace in your monitoring tool, an analytics event and a feedback queue. Each copy has its own owner, its own retention period and its own readers. The way to keep private data out of AI context and logs is to decide, field by field, what the model needs, what a log needs, and what neither needs, and to enforce that in code before the text is copied anywhere.
This article walks through the places a message travels, what published guidance says about each, a fictional example, a five-step approach and a test you can run with invented values. It is about engineering habits. It is not legal advice, it does not say which privacy law applies to you, and it does not rank model providers.
The message is copied more often than you think
Take one message in a support chat for a crypto wallet. It is assembled into a prompt and sent to a model provider, which may keep it. A request log or error handler may print the whole payload. A trace in a monitoring tool can record the model's inputs and outputs. An analytics event or a feedback queue may store the text again. The reply can carry private data too, if something upstream let it in.
OWASP's entry on sensitive information disclosure (LLM02:2025) defines the scope broadly: personal identifiable information, financial details, health records, confidential business data, security credentials and legal documents [1]. It names an application-level scenario as well: a user receives a response containing another user's personal data "due to inadequate data sanitization" [1]. That is a leak through the product's own design, not an attacker's cleverness.
The same page says restrictions in the system prompt about what data the model may return "can provide mitigation", but "may not always be honored and could be bypassed via prompt injection or other methods" [1]. A prompt line is a request, not a control. The controls below sit in code.
A fictional example
The following example is invented. Example Wallet is a made-up product, its assistant is a made-up support chat, and every value below is fake.
A user writes to the Example Wallet assistant:
Hi, I sent a top-up from card ending 0000 and it has not arrived. My name is Maria Example, my email is maria@example.test. Here is my transaction note: "top-up for March".
What does the assistant need to answer? The question is about a missing top-up. It needs the intent, the card's last digits (to match a record) and perhaps the date. It does not need the full name or the email in the prompt, because the application already knows which account the user is logged into and can look up the record by an internal account id.
In a typical first build, all of it goes into the prompt, the whole payload goes into a debug log "to see what the model got", the trace tool records inputs and outputs, and the "unrecognised questions" table stores the raw message. One message, four stored copies of a name and an email address, and no bad actor involved.

Step 1: Decide what each destination needs
Start from the destination, not the message. For each of the places above, write down which fields it needs to do its job:
| Destination | Needs | Does not need |
|---|---|---|
| Prompt | Intent, a record reference, the last digits | Full name, email, full card number |
| Provider | Whatever is in the prompt | Anything you did not put there |
| Application log | Request id, timing, outcome, error class | Message text |
| Trace | Operation name, model, token counts | Input and output bodies, by default |
| Analytics | Topic label, resolved or not | Raw text |
| Feedback queue | Rating, a reference to the conversation | A copy of the conversation |
The table is the author's working format, not a standard. The principle is in the guidance: OWASP's list of mitigations includes limiting access to sensitive data "based on the principle of least privilege", followed by: "Only grant access to data that is necessary for the specific user or process" [1]. Applied here: the prompt is a process too, and it should receive only what it needs. "Giving an Agent Only the Access It Needs" covers the same idea for tools; this applies it to text.
Step 2: Strip and replace before the text leaves your code
For the fields that do have to be in the prompt but are not needed in readable form, replace them with typed placeholders and keep the mapping in your application, never in the prompt:
Hi, I sent a top-up from card ending 0000 and it has not arrived. My name is , my email is .
The model can still reason about the message. If it later needs to refer to the person, it writes , and your code decides whether to put the real name back into the reply shown to this user. OWASP lists "Tokenization and Redaction" among its techniques, adding that "Techniques like pattern matching can detect and redact confidential content before processing" [1].
The open-source Presidio project, whose documentation now sits at a data-privacy-stack address that Microsoft's former Presidio page redirects to, is one example of a toolkit for this. Its documentation describes recognizers built from named-entity recognition, regular expressions, rule-based logic and checksums, and anonymizer operators that can replace, mask, redact or encrypt a detected entity, plus deanonymizers that revert an operation, for example by decrypting encrypted text [4]. It also carries a warning that matters more than the feature list: "because it is using automated detection mechanisms, there is no guarantee that Presidio will find all sensitive information. Consequently, additional systems and protections should be employed" [4].
Take that warning seriously for any detector. Strictly formatted fields such as card numbers with a checksum or an email address are easy to catch with a pattern. Free text, such as a casually written name or a detail inside a sentence, is not. So detection is one layer; the others do not depend on it: send less (Step 1), do not log bodies (Step 3), and test with seeded values (Step 5).
Two practical rules follow:
- Keep the placeholder mapping short-lived and on your side. It is private data too, with the same access rules and a deletion time you chose.
- Restore real values after validation, not before. If a model's output refers to , resolve it only after the output has passed whatever checks your application applies. The article "Validating Model Output Before an Action" covers that step.
Step 3: Make logs and traces content-free by default
Logs are the most common place for a leak, because they are written without a user in mind and read later by many people.
OWASP's Logging Cheat Sheet has a section called "Data to exclude". It says the following "should usually not be recorded directly in the logs, but instead should be removed, masked, sanitized, hashed, or encrypted", and the list includes access tokens, session identification values, authentication passwords, database connection strings, encryption keys and other primary secrets, bank account or payment card holder data, and sensitive personal data [2]. It also lists data that "may also need to be treated in some special manner", among them personal names, telephone numbers and email addresses, and suggests "deletion, scrambling or pseudonymization of direct and indirect identifiers where the individual's identity is not required" [2]. On session values specifically, it says to consider replacing them with a hashed value if you need to track session-specific events [2].
The cheat sheet adds that logs themselves are a target: they "may contain personal and other sensitive information", so they need protection against unauthorised access, modification and deletion, and, under "Disposal of logs", must not be kept beyond the required retention period [2].
For AI-specific telemetry, the OpenTelemetry project's generative AI conventions take a clear position. The text says "Model instructions, user messages, and model outputs are considered sensitive and are often large in size". It adds that instrumentations "SHOULD NOT capture them by default, but SHOULD provide an option for users to opt in" [3]. It then names three usage patterns: do not record content (the default); record content on spans, which it describes as suited to cases where "privacy regulations do not apply or the telemetry storage complies with them, for example, in pre-production environments"; or store content externally and put a reference on the span, which it recommends for production when sensitive data must be handled securely because "external storage enables separate access controls" [3]. The attributes that hold messages and instructions carry the warning that they are "likely to contain sensitive information including user/PII data" [3]. These conventions had "Development" status when read, so they may change [3].
In practice:
- Request and error logs hold ids, timings and error classes, never message bodies. Check what error handlers print: an exception that prints its arguments can write the whole prompt into a log.
- Traces record the model, duration and token counts. Content capture stays off in production unless there is a documented reason, a separate store and a named owner.
- To debug a bad answer, open one conversation by reference id in a restricted tool with recorded access, not by searching free-text logs.

Step 4: Read what each provider keeps, and plan for it
You control what you send. You do not control how long a provider keeps it. Read the retention page for the exact product and plan you use, and read it again when you renew or change plans, because these pages change.
Two examples as read on 2 December 2026, for orientation and not as a ranking:
- Anthropic's commercial retention page (dated 1 July 2026) says it automatically deletes API inputs and outputs "within 30 days of receipt or generation", with exceptions such as longer-retention services under the customer's control, agreed arrangements like zero data retention, policy enforcement and legal compliance. Inputs and outputs flagged as violating its usage policy are kept up to 2 years, and data attached to feedback submissions for 5 years [5].
- OpenAI's data controls page says that as of 1 March 2023 API data "is not used to train or improve OpenAI models (unless you explicitly opt in to share data with us)". Abuse monitoring logs, which "may contain certain customer content, such as prompts and responses", are by default "retained for up to 30 days, unless longer retention is required by law, or is reasonably necessary to protect our services or any third party from harm". Zero Data Retention and Modified Abuse Monitoring are "subject to prior approval by OpenAI", and some endpoints can still store application state [6].
A provider's retention is a window during which private data in your prompt exists outside your systems. Masking before sending shrinks what sits in that window, and it is the only part you can verify yourself; settings and contracts are read from documentation. Note also the feedback detail in [5]: a thumbs-down button in your product can send a conversation somewhere you did not plan for.
Step 5: Test with seeded values, everywhere text can land
A privacy design that has not been tested is a hope. The test is cheap, and it needs no real personal data. This is the author's proposal, not a published standard.
- Make canary values. Invent strings that cannot occur naturally, such as CANARY-NAME-7731 and canary-7731@example.test. Never use a real person's data or a working key.
- Send them through the real product in a test account, then send a second message that triggers an error.
- Search every store for the canaries: request and error logs, traces, analytics, the feedback queue, the conversation database, backups you can query, and the provider's dashboard if it has one. For each hit, check whether the Step 1 table allows it.
- Check the output side. As a second test user, try to make the first user's canaries appear in answers. "Testing User Isolation in an AI Product" covers that test.
- Repeat after changes to prompts, logging, error handling, tracing or vendor. A new library with verbose defaults can undo a good design in one deployment.
A clean result means the stores you searched held no canaries that day, for those inputs. Keep the list of stores written down and extend it whenever a store is added.
Four mistakes and fixes
1. Asking the prompt to protect itself. A system prompt line like "never reveal personal data" is treated as the only control. Fix: treat it as a hint and put the controls in code, as OWASP's warning about bypass implies [1].
2. Logging the payload "temporarily". A debug line prints the full request and stays in production. Fix: log ids and outcomes; open conversations through a restricted viewer [2][3].
3. Trusting one detector. The tool says it found everything. Fix: the maker's own warning is that detection offers no guarantee [4]; pair it with data minimisation and seeded tests.
4. Forgetting the side doors. Error handlers, analytics events, feedback buttons and backups hold copies too. Fix: include every one in the Step 1 table and the Step 3 search.
What this article does not settle
It does not tell you which privacy law applies, what must be disclosed to users, or when a regulator would call something personal data. It does not rank providers: the two retention summaries above are quotes about two products on one date, and the pages describe policy and settings, not outcomes. It does not show that any detector reaches a particular accuracy; the one tool described comes with the maker's own warning that it will miss things. The OpenTelemetry conventions were in Development status when read. The example is invented, and the table and the canary test are proposals: no source here measured how well they work. It also does not cover training-data leakage, which OWASP discusses under the same heading [1].
How this article was made
| Task | What the AI did | What a person did | How it was checked |
|---|---|---|---|
| Research | Gathered candidate sources and drafted notes | Chose the question and which pages to rely on | Every quote checked against the page named in the sources, read on 2 December 2026 |
| Draft | Wrote the first draft from the notes | Edited the text, the table, the example and the test | An independent review compares claims with the sources before publication |
| Images | Generated the cover illustration | Chose and checked it | Labelled as AI-generated in the disclosure line and alt text |
| Not done by AI | — | The decision to publish and responsibility for the text | — |
Conflicts of interest: none. The author has no commercial relationship with the organisations or products named here.
Responsible for this article: Dmitriy Lastovka, author. Corrections: contact form.
Sources
Labels: guidance (a project's or standards body's documentation), policy (a provider's published data-handling page). Quotes are as on the pages read on 2 December 2026.
- OWASP GenAI Security Project, LLM02:2025 Sensitive Information Disclosure. https://genai.owasp.org/llmrisk/llm022025-sensitive-information-disclosure/ Guidance.
- OWASP Cheat Sheet Series, Logging Cheat Sheet (sections "Data to exclude", "Protection" and "Disposal of logs"). https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html Guidance.
- OpenTelemetry, semantic conventions for generative AI ("Capturing instructions, inputs, and outputs" and the client inference span attributes), read from the project's semantic-conventions-genai repository, status Development. https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-spans.md and https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/client-inference.md Guidance; in development.
- Presidio documentation (home page and anonymizer page; the former address microsoft.github.io/presidio redirects here). https://data-privacy-stack.github.io/presidio/ and https://data-privacy-stack.github.io/presidio/anonymizer/ Guidance.
- Anthropic Privacy Center, "How long do you store my organization's data?" (dated 1 July 2026 on the page). https://privacy.claude.com/en/articles/7996866-how-long-do-you-store-my-organization-s-data Policy.
- OpenAI API documentation, "Data controls in the OpenAI platform" (section on types of data stored and retention controls). https://platform.openai.com/docs/guides/your-data Policy; no revision date on the page.










