Mehran Toosi · Principal Software Engineer · Copenhagen

2026 · TypeScript, Python · Cloudflare Workers, Durable Objects, Containers · Apache 2.0

Privacy Guard

problem

Agents need customer data to do real work, like sending a reminder to the right person or paying the right account. Sending names, emails and IBANs to a model provider is a GDPR problem, and one-shot redaction makes the agent useless.

solution

A service between the agent and the model provider. It replaces personal data with stable tokens backed by an encrypted vault per conversation, and restores real values at the tool boundary, so the model never sees them but the agent can still act on them.

results

In production behind ecoai at Visma e-conomic, and open source. Tokens stay consistent across a whole conversation, and anything that can’t be restored stops the action instead of guessing.

Architecture

A Worker routes each request. Detection runs in Python containers: rule-based recognizers for structured data like emails and IBANs, and a GLiNER model for names and addresses. Mappings live in a Durable Object per vault, encrypted with AES-GCM, in the EU.

anonymize before the model call, deanonymize before the tool runs · layout illustrative

consistency

The same person, the same token, every turn

Before detection runs on new text, the vault replays every mapping it already holds into that text, longest value first. Detection then only has to find what is new, and a value seen in turn one gets the same token in turn twenty. Identical values are matched through a salted SHA-256 fingerprint, so plaintext is never stored.

two turns of one conversation against the same vault · values and tokens illustrative

safety

Failing closed at the tool boundary

Models sometimes damage a token while copying it. Tool arguments are restored before anything runs, and a token with no mapping is preserved and reported instead of silently dropped. The harness treats that as fatal for any action with side effects, so a damaged token can never send mail to the wrong address.

In production the model damaged a token in 0.61% of responses over a three-month sample.

two tool calls from the model, one with a damaged token

availability

Detection that survives cold containers

Detector requests go to one of four container shards chosen by a hash of the content. If that shard is cold or restarting, the request moves around the ring with exponential backoff, up to two failover passes, so a container restart doesn’t fail the conversation.

four detector shards, one of them restarting