Xavier Fok
← All writing

· 6 min read

Stripping Customer Details Out Before A Prompt Leaves My Network

How I redact data before it hits an LLM: what gets stripped, what stays local, and where the placeholder-token approach actually breaks.

The moment this stopped being optional

I run agents that touch order data, support tickets, and billing records every day. Some of that work goes through cloud models because a local model just isn’t strong enough for the reasoning I need, things like triaging a messy support thread or summarizing a batch of tickets with inconsistent formatting. The problem is obvious the first time you sit down and actually read what’s in the prompt you’re about to send: a customer’s name, their email, sometimes a partial card reference, an order ID that maps directly back to a real person’s shipping address.

None of that needs to leave my network for the model to do its job. The model doesn’t need to know the customer is named Priya to tell me her order is stuck in a routing loop. It needs the shape of the problem, not the identity attached to it. So the rule became: redact data before it hits an LLM, every time, no exceptions for “this one’s probably fine.”

What actually counts as a customer detail

It’s tempting to think of this as just names and emails, but the list is longer once you look at real tickets:

  • Full names and any nicknames a customer used in chat
  • Email addresses and phone numbers
  • Physical addresses, even partial ones like a unit number
  • Order IDs and invoice numbers that link back to a person in my database
  • Payment references, even truncated ones
  • Anything a customer typed that identifies a third party, like “my husband’s card” or a referral’s name

The last one is the easy miss. People paste in details about other people all the time, and a rule that only looks for “the customer’s own info” walks right past it.

Splitting the pipeline into local and cloud halves

The architecture is simple on paper. Anything that touches raw customer data runs locally, on hardware I control, using either scripted logic or a local model. Only after that stage produces a sanitized version does anything get handed to a cloud API. The cloud model never sees the raw ticket. It sees a version with the identifying pieces swapped out for placeholders.

This means the pipeline has a hard boundary in it, not a soft one. It’s not “the agent is instructed to be careful.” It’s a separate process step that the raw text physically cannot skip, because the function that calls the cloud API only accepts the sanitized object, not the original string. If the redaction step throws an error, the request doesn’t go out. That’s the part that actually matters. A rule that lives in a prompt is a suggestion. A rule that lives in the code path is a gate.

How the redaction pass actually works

For structured fields, this part is easy and doesn’t need a model at all. Emails, phone numbers, and order ID formats are regular expressions. They match a pattern, get pulled out, and get replaced with a token like [EMAIL_1] or [ORDER_1]. This is fast, cheap, and deterministic, which matters because I want the same input to redact the same way every time.

Names are the hard part, because names don’t follow a pattern. “John” is a name and also a common word in other contexts. For this I run a lightweight local model as a first pass over the free text, tagging anything that looks like a person’s name, and swapping each one for a token. It’s not perfect. It catches most names in a ticket written in plain English. It’s less reliable on names embedded in weird formatting, like a signature block copied out of an old email chain, or names that get split across two lines.

Whatever the local pass produces goes through a second, cheaper check: a list of known customer names and emails pulled straight from my own database. If a raw string in the text matches a real record I have on file, it gets redacted regardless of whether the earlier pass caught it. This second layer exists because I’d rather over-redact a name that turns out to be a common word than under-redact one that’s actually a real customer.

Putting it back together without sending the mapping anywhere

Every token gets a mapping entry: [EMAIL_1] maps to the real address, [ORDER_1] maps to the real order number. That mapping table lives only on the machine doing the redaction. It never gets attached to the request, never gets logged in a place the cloud model or its provider can see, and never leaves the network the request originated from.

When the cloud model sends back a response, that response might reference [EMAIL_1] or [ORDER_1] directly, because the model was told those are placeholders standing in for real values. The local process swaps them back in before the response is used or shown to anyone. From the outside, the whole exchange looks like the model handled the ticket end to end. In reality it only ever saw a version of the ticket with the identifying pieces pulled out and replaced.

Where this breaks down

I’m not going to pretend this catches everything, because it doesn’t, and claiming otherwise would be exactly the kind of overstatement I try to avoid. A few honest gaps:

Free text is messy. A customer who writes “call me at oh six five, four four two…” spelling out digits instead of typing a phone number will slip past a regex built for standard formats. I’ve had to add patterns for spelled-out numbers and common obfuscations, and I still don’t consider that list complete.

Context can leak identity even without a name. If a ticket says “the order for the wedding invitations shipping to the address near the old post office in Tanjong Pagar,” that’s specific enough to identify someone even with every proper noun stripped. No token-based redaction catches implied identity like that. This is a judgment call issue, not a tooling one, and it’s why anything touching a genuinely sensitive case still gets a human look before it’s treated as fully anonymized.

The local model doing the name-tagging pass isn’t a specialized redaction tool, it’s a general local model doing a narrower job than it’s built for. It’s good enough for the volume I run, but I don’t treat its output as a guarantee. That’s the whole reason the second layer, the direct match against known customer records, exists as a backstop.

And redaction only covers what goes into the prompt. It says nothing about what a cloud provider does with a request once it’s received, what gets logged on their end, or how long anything is retained there. Stripping the identifying details before the request leaves my network reduces what’s exposed if something goes wrong downstream, it doesn’t make the downstream side someone else’s problem to solve for me.

What I’d actually tell someone setting this up

Start with the structured fields, because they’re the easy wins and they cover a large share of real exposure with almost no false negatives. Emails, phone numbers, order IDs, that’s a day of work with plain pattern matching and it removes most of the risk immediately.

Treat the free-text name detection as a filter that reduces exposure, not one that eliminates it, and back it with a direct match against your own records for anything you already know about a customer. And keep the redaction step as a hard gate in the code, not a note in a system prompt. A model can be told not to leak something and do it anyway if the raw data is sitting right there in its context. A function that refuses to make the request without a sanitized payload doesn’t have that failure mode.

None of this requires exotic tooling. It requires deciding, before the first prompt ever goes out, that raw customer data doesn’t get to leave the network unless someone made an active decision to let it.

If you want more of how I actually build and run this stuff day to day, come look around xavierfok.com.

Get new guides and videos first — join the Telegram channel.

Keep reading