Sub topic 2
Where personal data travels in an LLM app
This chapter assumes you know basic Python, have called an LLM API before, and understand what a prompt, a response, and a log are. It maps every point where personal data can enter, be stored, or leak. Later chapters cover detecting and redacting it at those points.
The request path is not the only path
Most people think of one flow: the user types a message and the app sends it to the model. A real application has more stages than that. Each stage can receive personal data, copy it, or store it.
The sections below follow the stages in the order data reaches them.
Entry points
Personal data can enter the app in four ways.
- User messages. Users paste emails, invoices, medical notes, or stack traces that contain customer records. You cannot control what they type.
- Retrieved documents. In retrieval-augmented generation (RAG), the app fetches chunks from a knowledge base and adds them to the prompt. If the knowledge base holds HR files or support tickets, those chunks carry personal data into every prompt that retrieves them.
- Tool results. When the model calls a function such as a CRM lookup or a database query, the result is added to the context. A lookup for one customer returns a full profile, often with more fields than the task needs.
- System prompts and examples. Developers sometimes put real names or sample records into prompts while testing. These then ship to production.
Storage points
Once data is in the app, it is often written somewhere that outlives the request.
- Application logs. Request and response logging is the most common leak. Logs are copied to monitoring tools, read by many engineers, and kept for months.
- Conversation history. Chat apps store past turns so the model can see earlier context. Each stored turn is a copy of everything the user said.
- Vector stores. If you embed user content for later search, the original text usually sits next to the vector. Embeddings can also leak information about the text they encode.
- Caches and analytics. Prompt caches, error trackers, and product analytics often capture payloads automatically.
Exit points
Data also leaves your control.
- The model provider. Every prompt is sent to a third party. Check the provider's retention and training policy, and your contract. Your own data policy decides whether sending the data is allowed at all.
- The response. The model can repeat personal data from its context, and it can show data from one retrieved document to a user who should not see it.
- Third-party services. Tracing platforms, evaluation tools, and tool APIs each receive a copy of some part of the traffic.
A worked example
Consider a support assistant. A user writes: "Why was [email protected] charged twice?" The app then does the following.
- It logs the raw message, so the email is now in the logs.
- It retrieves two past tickets about Ana, which add her name and address to the prompt.
- It calls a billing tool that returns her card's last four digits and her full billing history.
- It sends all of this to the model provider.
- It stores the whole conversation, including the tool output, in history.
One short question produced at least five copies of personal data in five places. Only one of those copies was typed by the user.
Finding your own flows
A short inventory helps. Walk through your app and fill in a table like this one.
| Stage | Can it hold personal data? | Who can read it? | How long is it kept? |
|---|---|---|---|
| User message | Yes | App, provider | Per request |
| Retrieved chunk | Yes | App, provider | Source lifetime |
| Tool output | Yes | App, provider, tool owner | Per request |
| Application log | Yes | Engineers, log vendor | Months |
| Conversation history | Yes | App, user | Until deleted |
Rows with a long retention time and a wide audience carry the most risk. Redaction effort should go there first.
Summary
Personal data reaches an LLM app through user messages, retrieved documents, tool results, and prompts. It is then copied into logs, history, vector stores, and caches, and sent to the model provider and other services. Detection and redaction must therefore be placed at several points, not only at the user input.
Exercise
A support assistant retrieves tickets from a vector store, calls a billing tool, and logs every prompt. The user's own message contains no personal data. Name two other places where personal data can still enter or be stored.
Show answer
Personal data can enter through the retrieved ticket chunks and through the billing tool's output. It can then be stored in the prompt logs, which record the full prompt including those chunks and tool results. Conversation history is also a valid answer.
Exercise
Your inventory table shows two rows: an application log kept for six months and readable by many engineers, and a per-request tool output seen only by the app and the provider. Which should you protect first, and why?
Show answer
The application log. It has a long retention time and a wide audience, so a leak there affects more people and lasts longer. The tool output is short-lived and has a narrow audience.