Skip to main content
Tokenize LLM prompts shows how an application masks personal data before it calls a model. That works when you own the code that calls the model. Often you do not: the agent is a coding assistant, a vendor product, or a framework that talks to the model provider directly and calls MCP tools on its own. For that case, Databunker Pro has the Zero-PII gateway. The agent’s model traffic goes through your API gateway, and the Zero-PII gateway does the masking there:
  • The user types real names and reads real names.
  • The tools (MCP servers, databases, APIs) receive real values in their arguments and return real data.
  • The LLM provider sees only placeholders such as [PERSON_1] and [EMAIL_1].
  • Databunker Pro holds the values, each one an encrypted token.
The agent is unchanged: you point its model base URL at the gateway. The Zero-PII gateway connects through Envoy’s external processing (ext_proc) protocol, so it works with any API gateway that supports that protocol, such as agentgateway, as a separate gRPC service.

What each party sees

A user asks an agent with a BigQuery MCP tool:
The model still reasons about the data: it knows there is one person, one email and one phone, and which is which. Business data the Zero-PII gateway does not classify as personal, such as products, amounts, dates and cities, reaches the model unchanged, so it can summarize and calculate.

Architecture

The API gateway sends each model request to the Zero-PII gateway before forwarding it, and each answer before returning it. The MCP route does not go through the Zero-PII gateway: tool calls carry real values, and stay between the agent and your own tools.

Example: agentgateway

agentgateway is an open-source gateway for AI agents, with LLM and MCP routes in one place. Its extProc policy sends the LLM route through the Zero-PII gateway, with no change to agentgateway itself:
  • ai.routes tells agentgateway that the route speaks the Anthropic Messages API, so it forwards requests in that format instead of translating them.
  • extProc calls the Zero-PII gateway for every request and every streamed answer on this route. The MCP route has no extProc, so tool calls pass through with real values.
  • failureMode: failClosed rejects the request if the Zero-PII gateway is down.
Then point the agent at agentgateway. For Claude Code:
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS keeps Claude Code to request fields agentgateway already knows. mcp.json lists agentgateway’s MCP route:

One request through the Zero-PII gateway

  1. Request. The Zero-PII gateway reads the whole request and finds the conversation it belongs to. It loads that conversation’s vault from Databunker Pro and masks every user message, assistant message, tool call and tool result in it. New values are tokenized with one TokenCreateBulk call, and the masked request goes on to the provider.
  2. Answer. Agents stream, so the Zero-PII gateway restores the answer chunk by chunk, in text and in tool-call arguments. A placeholder split across two chunks ([PERS + ON_1]) is held back until it is complete. Values inside tool arguments are JSON-escaped, so a restored name never breaks the arguments.
The agent resends the whole conversation on every turn. The Zero-PII gateway caches what it has already masked, so a long conversation costs one detection pass for the new text only.

The whole agent run

One question can take several model calls, with tool calls in between. Every model call is masked, every answer is restored, and the tools run on real values: A follow-up question in the same conversation, such as “What was the day of his last purchase?”, uses the same vault: Michael Johnson is still [PERSON_1].

Conversations and sessions

Each conversation has its own vault, so [PERSON_1] means one person in one conversation and nothing outside it. The Zero-PII gateway finds the conversation from the agent’s session header, or from the session id in the request metadata. Without either, the first user message identifies it. The vault lives in Databunker Pro, as in Tokenize LLM prompts: one token per value with unique: true and a sliding expiry, and a session file that maps the conversation’s placeholders to token UUIDs. API gateway and Zero-PII gateway instances keep no state between requests, so you can restart or scale them, and a conversation continues on any instance.

Telling the model about placeholders

A model that sees [PERSON_1] may say the name is “redacted”, or refuse to put a placeholder into SQL. The Zero-PII gateway adds a short note at the end of the system prompt:
The note goes after the agent’s own system blocks, so the agent’s prompt-cache breakpoints stay valid. The agent’s own system prompt is not masked by default: it holds the agent’s instructions, and some providers validate parts of it.

Failure handling

The API gateway is configured to fail closed: if the Zero-PII gateway is not reachable, the model request is rejected instead of being sent unmasked. If Databunker Pro is not reachable, the Zero-PII gateway cannot load or save the vault, and the request fails the same way.

What this does not protect

Everything in What this does not protect applies, and the gateway adds a few points of its own:
  • Tools see real data. That is the point, and it means a tool that sends data to a third party sends real data. Put only tools you trust behind the gateway.
  • The model writes queries with placeholders. A value the model has to change, rather than copy, cannot be restored. For example, LIKE '%[PERSON_1]%' works, but splitting a name into first and last name does not.
  • Thinking stays masked. The provider signs extended-thinking blocks, so the Zero-PII gateway does not restore them. The user may see placeholders there.
  • Images and documents are not scanned. Only text, tool calls and tool results are masked.
  • Compressed answers are not restored. The Zero-PII gateway asks the provider for uncompressed answers. If a provider compresses anyway, the answer passes through unchanged and the Zero-PII gateway logs a warning.