← BlogAI Product Development

How to Stop Customer PII Reaching Your LLM Provider: A Pseudonymization Vault Architecture for AI Agents

By Aditya JhaSeptember 20, 202610 min read

How to Stop Customer PII Reaching Your LLM Provider: A Pseudonymization Vault Architecture for AI Agents

A fintech in Amsterdam wires a new support agent to its ticketing system, and within a week the data protection officer asks a question the engineering team can't answer: what exactly leaves our network when the agent summarises a ticket? The honest answer is everything. The customer's full name, IBAN, home address and the free-text paragraph about their health-related payment hardship are all concatenated into a prompt and sent to a model provider's API. Nobody was careless; the framework simply passes whatever the workflow gives it. The fix is not a stricter policy PDF. It is an architectural layer between your data and the model, a PII firewall, that swaps identifying values for placeholders before the call and restores them after. Here is how that layer works, where it breaks, and what it does and does not do for GDPR.

Why is sending raw customer data to an LLM API a compliance problem?

Because every prompt is a data transfer to a processor, and the more personal data it contains, the larger the surface you have to justify. Under GDPR that means a lawful basis, a data processing agreement, transfer safeguards if the provider processes outside the EEA, and data minimisation: send only what the task needs. A summarisation task rarely needs the customer's name or IBAN, yet the default pipeline sends both.

The same logic shows up in India's DPDP Act, in HIPAA-regulated healthcare builds, and in the broader GDPR obligations for AI agents. Minimising what the model sees is the one control that helps under all of them, and it also shrinks your exposure to the shadow AI problem, where staff paste raw records into unsanctioned tools.

What is a PII firewall, step by step?

It is a service that sits in front of every model call and performs four operations: detect, tokenize, call, rehydrate. The model works on a version of the text where identifying values have been replaced by typed placeholders, and the mapping between placeholder and real value never leaves your infrastructure.

  • **Detect.** An analyzer scans the text for personal data. Microsoft's open-source Presidio combines named entity recognition, regular expressions, rule-based logic, checksum validation and contextual analysis, and supports custom recognizers for your own identifiers such as internal customer IDs.
  • **Tokenize.** Each detected span is replaced with a typed placeholder such as PERSON_1, EMAIL_1 or IBAN_1. The same real value always maps to the same placeholder within a session, so the model can still resolve who did what.
  • **Vault.** The placeholder-to-value mapping is written to an encrypted store scoped to the request or session, with a short time-to-live and strict access control. This is the additional information that keeps the data pseudonymised rather than exposed.
  • **Call and rehydrate.** The redacted prompt goes to the model. The response, which refers to PERSON_1 and EMAIL_1, is passed back through the firewall, which substitutes the real values before the answer reaches the user, the CRM or the next workflow step.

Why do typed, consistent placeholders beat blanking values out?

Because a model reasons over structure, and a blank destroys it. If you replace every name with the same string, the model cannot tell the customer from the agent in a ticket, and a summary that says the person emailed the person is useless. A typed placeholder like EMAIL_1 tells the model it is an email address, so it can still draft a reply that asks the customer to confirm the address without ever seeing it.

Consistency matters for the same reason: within a conversation, PERSON_1 must stay PERSON_1 across every turn and every tool call, or coreference breaks. This is also a context-management concern, so the mapping should live alongside your agent memory design rather than being regenerated per message. Decide deliberately what not to redact: if the task depends on an amount or a date, masking it breaks the output, so use generalisation instead (an age band rather than a birth date, a city rather than a street address).

Is pseudonymised data still personal data under GDPR?

Yes, and this is the point most vendor pages blur. The EDPB's Guidelines 01/2025 on pseudonymisation, published for consultation in January 2025, state as summarised by Hunton Andrews Kurth that pseudonymised information is still personal data, because additional information exists that could identify the individual. The guidelines introduce the idea of a pseudonymisation domain: an environment where the additional information needed for attribution is excluded and kept separate from those who must not be able to re-identify people.

In practice this means your PII firewall reduces risk but does not take the model provider out of GDPR scope by itself. Its real value is threefold: the provider receives far less identifying data, a breach on their side exposes tokens rather than identities, and the guidelines note pseudonymisation may serve as a supplementary measure for international transfers under Article 44. It still sits alongside, not instead of, a signed DPA, a region choice and zero-retention settings.

Where does automated PII detection fail?

In exactly the places you'd expect, and the vendor says so plainly. Presidio's own documentation warns that because it uses automated detection there is no guarantee it will find all sensitive information. Recall, not precision, is the metric that matters here: a false positive costs you a slightly garbled prompt, a false negative sends a real name to a third party.

Failure modeWhy it happensMitigation
Missed names in non-English or unusual formatsNER models are trained mostly on English news-style textAdd a second detector (a local model pass), custom recognizers, and test on your own language mix
Quasi-identifiers slip throughJob title plus employer plus city can re-identify someone with no name presentGeneralise fields, and drop free-text sections the task doesn't need
Identifiers inside pasted contentEmail signatures, forwarded threads and attachments hide values in noiseRun detection on the fully assembled prompt, not just the user field
Model mangles a placeholderThe LLM rewrites PERSON_1 as Person 1 or omits itValidate that every placeholder survives, and fail closed or retry if one is missing
Sensitive classes that shouldn't be tokenised at allCard numbers, government IDs or health details are too risky even pseudonymisedPolicy layer: block the call or route to a self-hosted model instead of tokenizing

Common failure modes of a PII firewall in front of an LLM, with mitigations. Based on our build practice.

How do you build this into an n8n or agent workflow?

Run the firewall as its own service and call it from a reusable sub-workflow, so no team can add an AI node that bypasses it. Deploy the analyzer as a container next to your automation stack, expose one endpoint that takes text and a session ID and returns redacted text, and put a matching rehydrate endpoint after the model node. This mirrors how you'd isolate other risky capabilities in an agent's tool permissions.

Three details separate a demo from production. First, apply the same treatment to tool-call arguments and retrieved documents, not just the user message, because retrieval and tool outputs re-inject data into the prompt. Second, log only the redacted prompts in your observability stack; if raw text lands in trace logs or in your workflow tool's saved execution history, you've rebuilt the leak downstream, so configure retention deliberately. Third, budget for latency: a detection pass runs before every call, so measure it against your time-to-first-token target instead of assuming it's free.

How do you prove the firewall works?

Build a labelled test set from real (consented or synthetic) records, mark every identifier by hand, and score the firewall on recall per entity type: names, emails, phone numbers, addresses, financial identifiers and your custom IDs. Track it as a release gate, the same discipline used to evaluate agents before production, and re-run it whenever you change the detector, add a language or onboard a new data source. Keep a detection log (what type was found, how many, never the value) so your DPO can evidence the control to a regulator or an enterprise customer's security questionnaire.

How AIBOOTSTRAPPER solved this for a client

There isn't a case study where the published outcome is a PII firewall specifically, so here is the closest genuine parallel. For ComplyNexus, a Hong Kong compliance team was tracking changing regulations in spreadsheets with constant risk of missed obligations. We built a RAG-powered engine that monitors regulatory sources, maps new rules to the client's controls and surfaces gaps with audit trails, and the delivered results were 92% less manual review time, regulatory-change turnaround cut from three weeks to two hours, and 100% audit-ready traceability.

That traceability is the principle a privacy layer depends on: every automated decision has to leave evidence a regulator can inspect. When we design AI agents that touch customer or patient data, we start from what the model needs to see and what it must never see, then build the detection, vault and logging around that boundary. To review your own data flow, see our AI product development services or book a call.

Want this done for you?

Book a free strategy call and we'll show you how to build and market your business with AI.

FAQ

Questions, answered

Everything you might want to know before we hop on a call.

No. Redaction with a reversible mapping is pseudonymisation, and the EDPB's 2025 guidelines treat pseudonymised data as still personal data. It reduces risk and data exposure, but you still need a lawful basis, a data processing agreement, transfer safeguards and data minimisation decisions.

Pseudonymization replaces identifiers with tokens while keeping a separate mapping that can restore them, so the data can still be attributed to a person with additional information. Anonymization removes that possibility entirely, which is far harder to achieve with free text and is not what a reversible placeholder pipeline gives you.

No. Presidio's documentation states that, because detection is automated, there is no guarantee it will find all sensitive information. Treat it as one layer, measure recall on your own data, and add policy blocks for the highest-risk categories.

It adds a detection step before every model call, so there is some latency cost that depends on your detector and hosting. Measure it against your response-time target, keep the analyzer close to your workflow engine, and cache the mapping for the session instead of recomputing it each turn.

Keep reading

Let's talk

Ready to build and sell with AI?

Book a free 30 minute strategy call. We'll map the highest ROI AI move for your business, no pitch, just value.