Skip to main content

Privacy masking

When an agent sends a message to a model, that text goes to the model provider, such as OpenAI or Anthropic. If the message contains a customer's name, phone number or medical details, that personal data leaves your control.

Privacy masking stops that. Turn on privacy_enabled and every message goes through two steps:

  1. Sanitization. Before the model sees anything, Guardian Layer finds the personal details and replaces them.
  2. Rehydration. When the model replies, the original details are put back, so the user gets a complete, personal answer.

How it works​

User: "Hi, I'm Dana Reyes, call me on 415-555-0123 about my knee."
↓ 1. Sanitize: Guardian Layer replaces personal details
Model sees: "Hi, I'm [PII_1], call me on [PII_2] about my knee."
↓ the model writes a reply
Model says: "Thanks [PII_1], a nurse will call [PII_2] today."
↓ 2. Rehydrate: the original details are put back
User sees: "Thanks Dana Reyes, a nurse will call 415-555-0123 today."

The same value always gets the same stand-in within a message. That way the model can still follow who is who, even though it never learns the real details.

Detection uses Guardian Layer, the same service you can call on its own.

The Default mode​

privacy_enabled uses Guardian Layer's Default mode. It's built for conversations. It sanitizes each message, replacing details with labels such as [PII_1] and [PII_2]. Then it rehydrates the reply, putting every original detail back.

ModeModel or reader seesUse it when
Default (agents)[PII_1]Users should get a complete, personal answer
TransformMaria LopezYou want realistic text, such as test data or analytics
MaskingD*****You need to show that data was removed
Placeholder[NAME]You want to keep the type of data but not the value

Transform, Masking and Placeholder are for calling Guardian Layer directly. See the Guardian Layer overview.

What it covers​

  • Every message the model sees: the system prompt, examples, the conversation so far, and passages retrieved from your files.
  • These kinds of data: names, phone numbers, ages and dates, by default.
  • Every agent where it's turned on. In a squad, set privacy_enabled on each agent that should be private.

When to use it​

  • Health, legal, HR or financial conversations.
  • Any agent where users might type personal details, even if they shouldn't.
  • When your policy or customers require that personal data isn't sent to AI providers.

The model still answers well, because it only needs to know that "a person" called about "their knee", not who they are.

See it in code: Private agent template.