Skip to content

PII Protector

PII Protector is a Tier 2 (sidecar HTTP call, milliseconds) guardrail that provides reversible PII tokenisation. It detects PII in the request body using a locally hosted NLP engine running within Myra's certified infrastructure, replaces each detected value with an opaque token, forwards the tokenised request to the AI provider, and restores the original values in the response before it reaches the client. When a request egresses to an external AI provider the model never processes real PII, and the engine never transmits data outside the Myra perimeter. A request that routes wholly to a first-party local (Myra/EU) model is served unmasked — the data never leaves Myra, so masking is skipped (see Local model legs are not masked below).

Screenshot: PII Protector editor in the Guardrail Builder PII Protector editor

When to use PII Protector

Use PII Protector when the AI model needs contextual continuity — the ability to reference names, addresses, or other PII naturally — but the real values must not reach the provider. For permanent, irreversible scrubbing without restoration, use the NLP PII Detector with action: "scrub" instead.

How it works

  1. Request phase — The NLP PII detection engine scans the request body for PII spans. Each unique value is replaced with a token in the format [MYRA-REDACT-{TYPE}:SALT:N], where TYPE is the detected entity type (e.g. EMAIL_ADDRESS, US_SSN), SALT is a conversation-stable prefix, and N is a content-derived hex identifier. The same original value always maps to the same token within a single request.
  2. Provider call — The upstream AI provider receives only the tokenised body. Real PII values are never transmitted.
  3. Response phase — All tokens present in the response are replaced with their original values before the response is sent to the client.

⭐ Example: A prompt containing "My SSN is 123-45-6789" is forwarded to the provider as "My SSN is [MYRA-REDACT-US_SSN:a3f1c2:9b1d4f7a2c3e]". If the model echoes the token back, the client receives the response with 123-45-6789 restored.

The detection engine is language-agnostic — the same multilingual model reads German, English, French, Dutch, Danish and other Latin-script text, and the language value does not change which spans it returns — so no language field is required for detection to work. language is nonetheless not inert: it is the calibration control, and it decides the PERSON / LOCATION confidence floor. Every value except explicit English applies the 0.6 floor for names and addresses — absent (the fail-safe choice), "de", "da", "fr" and any other locale. Setting it to "en" (or an en- region such as "en-GB") raises that floor to 0.9, which is correct for English text but means German, Danish or other names and cities scoring 0.6–0.9 — a plain "Klaus Müller" ≈ 0.79, a city ≈ 0.71 — are no longer masked — in English text. A masking detector set to English still applies the 0.6 floor to any scanned text that reads as German, Danish, Norwegian, Swedish, French or Dutch (see Non-English content on an English detector), and on Automatic or English a field that reads as Danish is sent to the analyzer as language: "da" without setting the detector to Danish. (Before this release any explicit non-German locale raised it.) A request that ran without the floor for this reason records the pii_floor_off_by_language marker in its request log, and the Guardrail Builder asks for confirmation before applying the change. Under a PII mandate the floor is applied whatever language says, so on a mandated request the choice changes nothing about the floor (it still decides whether Danish text is sent as "da": Automatic and English do, other explicit languages send their own value).

💡 Note: PII Protector does not have an action field — it always tokenises rather than blocking or flagging. The same is true of the Custom PII Detector. Because the field was previously accepted and stored without ever being read, the API now enforces the truth in both directions:

  • Writes are rejected when they INTRODUCE or CHANGE such a value. POST /gateways (which is an upsert), PATCH /gateways/{id}, and the guardrail-config import and dry-run all return 400 for a pii_protector or custom_pii detector whose action is anything other than "scrub", naming the detector and the conflict. Omitting the field — the normal shape — and the explicit "scrub" are always accepted.
  • A value already stored is carried through, not rejected. The rule is about what a write changes: a configuration saved before this rule that carries "action": "block" keeps working, and a later save that leaves that detector alone still succeeds — otherwise the whole Guardrails section of that gateway would become unsaveable, since there is no control that could remove the field. Changing it to another contradicting value is a new claim, and is refused. Editing the detector list in the admin console's Guardrails section drops the inert field on save, so a configuration touched there cleans itself up, and the guardrail-config export strips it too (so an exported file imports into any gateway, not only the one it came from). A save from any other surface carries the stored value through unchanged.
  • Reads report what the detector does, not what was stored. GET /gateways/{id}/detectors reports the action of these two types as "scrub" regardless of what is stored. Previously the stored value was echoed back verbatim, so the API stated that a gateway had a blocking PII guard when it had a masking one.

It does take a target field, and on the non-streaming (buffered) path you must set "target": "both". Tokenisation runs on the request phase and restoration runs on the response phase, so both phases must be in scope. With the orchestrator's default target of "request", the request is tokenised but the response is never restored — the client then receives raw tokens. (Streaming restore is handled separately; the buffered path needs "target": "both".)


Configuration reference

Field Type Default Description
type string — Must be "pii_protector"
name string — Human-readable label for this guardrail instance
target string "request" Set to "both" so the request is tokenised and the response is restored. The default of "request" tokenises the request but leaves response tokens un-restored.
entities array absent Entity types to tokenise. Leave the field out to tokenise all supported entity types. An empty array [], null, a non-array, or an array containing a non-string or blank element is rejected with 400. A list already stored as [] keeps tokenising every type until it is next saved. Saving the gateway's guardrails is refused until All entities is clicked on that detector (or at least one type is ticked).
score_threshold number 0.7 Minimum confidence score for a detection to count: a finite number in 0.0–1.0, kept exactly and sent as written. null, a string, a boolean, an object or an out-of-range value is refused with 400 naming the detector and field (create, update, import, dry-run); the exact refused values are listed in the Presidio page note.
entity_score_thresholds object absent Per-entity confidence overrides (e.g. { "PERSON": 0.85 }) that take precedence over score_threshold for the named entity. Must be an object of entity type to a number in 0.0–1.0, else 400 on every write path (create, update, guardrail-config import and dry-run, and the tenant guardrail baseline); omit it for no overrides (an empty [] or {} also means none, null is refused). Not grandfathered: every write is checked.
de_recognizers boolean false When true, enables the German structured-ID recognizers on this detector (gates the whole German-ID feature). The age recognizer (German and Danish phrases) is not behind this flag and runs when the request is handled as German (Date of birth and age). A stored non-boolean value (e.g. null) is read as on — and the card shows it checked.
dk_recognizers boolean false When true, enables the Danish CPR recognizer (DK_CPR, placeholder [CPR]): separated CPR numbers (010190-1234, 010190 1234) always, a bare 10-digit CPR only in a request that mentions CPR (any message, the rest of a fetched page or document). No checksum (abolished for new CPRs in 2007). Runs offline. Also masks a CVR / SE number, bank account, passport or driving-licence number when a label stands right before it (never an unlabelled number; these five are masked, not a block signal) — see Labelled Danish identifiers. It also masks Danish phone numbers as the analyzer's own PHONE_NUMBER type (placeholder [phone]): written in pairs (24 66 81 90), with +45 / 0045, or after a phone label (tlf., telefon, mobil, …); an unlabelled 23456789 stays. The phone recognizer masks whenever this flag is on, regardless of the entities selection (Danish phone numbers). Also makes the gateway refuse a URL fetch or MCP tool call that carries a separated CPR, or a bare one under a CPR-named parameter or key such as ?cpr=0101901234 (see Block signal below). A non-boolean is refused on write; a stored one reads as on. Details: Danish CPR recognizer.
dob_recognizer boolean false When true, masks a labelled date of birth (geb., Geburtsdatum, DOB, a * date, a Geburtsdatum table column) regardless of the DATE_TIME threshold; unlabelled dates stay readable. Off by default — the gateway admin enables it. A write that introduces a non-boolean is rejected with 400 on every write path; a value already stored is carried through. See Date of birth and age.
language string | null absent The NLP calibration for this detector, and the language sent to the analyzer. It decides the PERSON / LOCATION confidence floor: every value ⇒ 0.6, except a well-formed explicit English locale ("en", "en-GB", "en_US") ⇒ the English 0.9 (since this release; a malformed value such as "en-" keeps 0.6). On an English detector, scanned text that reads as German, Danish, Norwegian, Swedish, French or Dutch still gets 0.6. On Automatic (absent) and English, a field that reads as Danish is sent to the analyzer as "da", exactly as a Danish-configured detector. See German names and addresses. Exposed in the Guardrail Builder as Language calibration on this card. The "" / non-string readings in this row describe what the runtime does with a value already stored; a write that introduces one is refused — see the accepted-shape note below.
allow_list array | null null Values the analyzer never reports, regardless of confidence score, so they are not tokenised. It applies to the analyzer's detections only: the gateway-side recognizers (German and Danish identifiers, Danish phone numbers, date of birth, age) do not read it
allow_list_match string "exact" How allow-list entries are matched: "exact" (the analyzer's default — omit the field to get it) or "regex". "partial" is not a value the analyzer serves: it returns HTTP 500, which the detector reports as an error and a fail_open: true detector then turns into an unmasked pass — measured against the live analyzer, deterministically, on every request. A write that introduces any other value is rejected with 400 (a stored one is grandfathered), and at runtime an unsupported value is treated as absent, which is the exact default: narrower allow-listing, i.e. more masking. The Guardrail Builder no longer renders a control for this field — its only non-default option was the broken one — so it is API-only.
skip_system_messages boolean true When true, every message except the system role (system and developer) is scanned: user messages, earlier assistant answers, tool results and any other role. When false, system and developer messages are scanned as well. The non-message carriers prompt and input are scanned either way (they are the caller's own text), except that a system or developer message item inside a Responses-API input array follows this setting like a system message does; instructions — the Responses-API system prompt — is scanned only under the widened scope, alongside the native top-level system. Ignored (forced full-scope) on a tenant with pii_masking_enforced — see mandatory masking. Only an absent value or true keeps the default; any other value (for example the string "false", 0 or null) is read as false and widens the scan. The same setting decides whether this detector masks the stored instructions the gateway composes into the system prompt — see Stored content in the system prompt
timeout_ms integer 15000 Deprecated / no longer read on the analyze path. Message fields are analysed through the chunked scanner (see below), which sets its own per-chunk read timeout. Retained only as a defensive floor. Minimum 1000 ms, and a whole number — a value below that cannot complete a real call, so the detector becomes a guaranteed timeout and, on a fail_open detector, the request is forwarded unchecked. Values outside [1000, 120000], non-numeric values and an explicit null are rejected with 400; a value already stored on a detector is carried through unchanged. The runtime also clamps to [1000, 120000], so an out-of-range value that predates this rule is corrected rather than obeyed.
fail_open boolean true When true, sidecar errors allow the request to pass through without tokenisation; when false, they block it Overridden on a request under a PII mandate: a pii_mandatory project (or a tenant with masking enforced) refuses the request when this detector's sidecar is unavailable, even with fail_open: true — see When the masker is down. It is the one setting a mandate outranks — on the request and response phases and at the two tool seams: under a mandate an outage withholds the web-search query (the search is skipped) and withholds a tool result (placeholder), whatever this flag says; the row records pii_mandate_masker_unavailable. Outside a mandate the seams honour the flag: true forwards the query / the result with at most the offline German-ID masking applied — and records that forward as a gap (guardrail_degraded / pii_scan_degraded / guardrail_error); false withholds. A tool result bound for a wholly-local model leg is never a mandate case and its forward is not a gap. Accepted shape: a real boolean. A write that introduces null or any non-boolean is rejected with 400 on POST /tenants/{id}/gateways, PATCH /gateways/{id} and the guardrail-config import; a value already stored is carried through. A non-boolean is read as absent by every phase (its own default: proceed on request/response, withhold at the tool seams) while the card shows it as a real choice — so it is refused rather than stored

⚠️ Accepted / rejected shape — language and allow_list_match; runtime coercion only for allow_list. A write that introduces or changes language to anything other than a usable locale string — null, a number, a boolean, an object, whitespace only, or a string carrying a control character — is rejected with 400, naming the detector; a value already stored is carried through unchanged so an existing configuration stays saveable. At runtime any non-string value — and any string carrying a control character, which is unusable rather than merely unrecognised — is treated exactly as an absent one and resolves to "auto", which is calibrated as German, so a malformed value masks more, never less. (A real non-English locale such as "fr" is a deliberate choice: it keeps the 0.6 score floor and is passed to the analyzer verbatim. Only an explicit English locale such as "en" raises the floor to 0.9, and even then not when a PII mandate applies or the scanned content itself is non-English.) allow_list_match has a write rule of its own: a write that introduces or changes it to anything other than "exact" or "regex" is rejected with 400, naming the detector; a value already stored is carried through so the configuration stays saveable, and the Guardrail Builder drops it on the next save of the Guardrails section. At runtime an unsupported value is treated as absent, which is the analyzer's exact default — narrower allow-listing, i.e. more masking. allow_list itself is not rejected at the write and is coerced at runtime only: a non-array, or one with no usable string element, is treated as absent, which allow-lists nothing — so a malformed value masks more. For allow_list_match the rule is about the VALUE, not only the shape: anything other than exact or regex — including the "partial" this field's editor used to offer — is treated as absent, because the analyzer answers 500 to it and that 500 fail-opens the detector. Absent is the exact default, i.e. narrower allow-listing.

This is not cosmetic. Previously a stored "language": null — JSON null decodes to a truthy value in the gateway runtime, so it survived the "or use the default" fallback — threw while the analyzer request was being built. The guardrail orchestrator recorded that as a detector error, and a detector shipping the default fail_open: true then forwarded the request completely unmasked, with only a log line. A single null disabled the PII layer for every request on the gateway. On a gateway under a PII mandate the same value produced an outage instead of a leak — the turn was refused with pii_mandate_masker_unavailable — which is the correct direction, and the reason the leak went unnoticed on the tenants most likely to report it.

Large messages: chunked analysis and the scan budget

A single message can be large (a pasted document, an inline data file, a long non-Latin body). Sending it to the analyzer in one call would exceed the sidecar's read timeout under load and fail the whole turn closed. Instead, each field is split into ~16 KB chunks analysed independently (30 s per chunk, up to 2 transient retries), under one 90 s total wall-clock budget shared across the turn's fields. The chunks are scanned concurrently (bounded fan-out), so a large document fits inside the budget instead of summing serially past it. When the budget is exhausted, the scan fails per the field's fail_open setting exactly as any other analyzer error (a fail_open: false gateway blocks; a fail_open: true gateway forwards with whatever offline masking applied, flagged as a degraded PII scan). A message field whose bytes are not valid UTF-8 is analysed in a single un-chunked call (chunk offset arithmetic requires valid UTF-8). These bounds are configured by your operator.

Pre-scan size gating and the honest "document too large" message. Before spawning each batch of concurrent chunks, the gateway projects whether the remaining chunks can finish before the budget deadline — the first batch against a conservative optimistic floor, later batches against this scan's own measured chunk latency. A scan that provably cannot complete in time (an enormous document, or a normally-sized one against a degraded sidecar) is refused fail-closed before it grinds the whole budget to the wall, and the refusal is surfaced as a distinct, retryable outcome — "This document is too large to scan for personal data right now. Please try again in a few moments." — rather than the generic "safety check temporarily unavailable". A retry genuinely converges: the chunks that already scanned are cached (per-chunk, 1 h TTL), so a re-upload measures faster batch times and fits. On a chat turn this is the guardrail_doc_too_large policy bubble (with a Try again action); non-chat callers receive the typed guardrail_doc_too_large 503, distinct from the generic guardrail_unavailable. A healthy document against a healthy sidecar is never falsely refused — a fast (or cache-hit) batch projects to a tiny remaining time and the scan proceeds normally.

Cached analyzer scores are kept exactly as the analyzer returned them, so a cache hit decides the same way as the first analysis. A payload that cannot be encoded exactly is not sent to the analyzer and is not retried.


Entity types and FP risk

PII Protector uses the same entity types as the NLP PII Detector. See that page for the full list of supported entity types and their benchmarked false-positive rates.

The 14 low-FP types are: EMAIL_ADDRESS, PHONE_NUMBER, US_SSN, CREDIT_CARD, US_BANK_NUMBER, IBAN_CODE, US_PASSPORT, PASSPORT, US_DRIVER_LICENSE, US_ITIN, CRYPTO, IP_ADDRESS, MEDICAL_LICENSE, URL.

PASSPORT covers passport numbers in any format or language via NER. US_PASSPORT covers only US-format numbers via regex. Both can be active simultaneously. US passport numbers are in practice detected under PASSPORT only: US_PASSPORT scores at most 0.1.

Six of the 14 types are not detected at the default score_threshold of 0.7: IP_ADDRESS, URL and US_ITIN score at most 0.6 / 0.6 / 0.5 (add entity_score_thresholds, for example { "IP_ADDRESS": 0.6, "URL": 0.6, "US_ITIN": 0.5 }), and US_DRIVER_LICENSE, US_BANK_NUMBER and US_PASSPORT are not reliably detectable at any sensible threshold. MEDICAL_LICENSE means US DEA registration numbers with a valid check digit. Details and the reasoning: Presidio page.

Field-name nouns the NER model mislabels — "email" or "gmail" as an email address, "phone" as a phone number, "passport number" as a passport — are not masked: a structured-type span whose whole text is on a closed list of such nouns is dropped before masking. Anything not on the list stays masked. See Field-name nouns tagged as structured PII for the list; role nouns tagged as names ("person", "user", "der Mitarbeiter") are handled by the PERSON stop-list.

The named-entity types — ORG, PERSON, LOCATION, DATE_TIME — are useful for contextual continuity but produce more false positives on general text. The gateway automatically raises score_threshold to 0.85 for ORG and to 0.9 for DATE_TIME when they are included. PERSON and LOCATION use a 0.6 floor by default; their threshold is raised to 0.9 only when language is configured explicitly as English ("en", "en-GB", …). With dob_recognizer: true, a date of birth that follows a label (geb., Geburtsdatum, DOB, …) is masked regardless of the DATE_TIME threshold by the offline DATE_OF_BIRTH recognizer — see Date of birth and age; unlabelled dates are deliberately left to the threshold so clinical timelines survive.


Token format

Tokens use the format [MYRA-REDACT-{TYPE}:SALT:N]:

Component Description
TYPE Detected entity type (e.g. EMAIL_ADDRESS, US_SSN, PHONE_NUMBER, CREDIT_CARD) — letters, digits and _ only, at most 32 characters when minted. The response-side cleanup recognises a TYPE of up to 63 bytes, so a token written with a longer type is not restored or cleaned as a token. Falls back to PII if the type is unavailable or the detection engine reports a label outside that shape (the label is untrusted input; anything else would break the token grammar the response-side restore relies on).
SALT 6-character hex prefix derived from the master key, the tenant, the signed-in user and the conversation identifier, so it is stable across every turn of a conversation. When there is no conversation (for example, a scrub preview or a raw compat call), the salt is derived per request instead.
N 12-character content-derived hex identifier, a one-way digest of the original value under a second key derived from the same secret scope — a key that never appears in any token. It is identical across the turns of a conversation for the same value (so a masked prompt prefix stays byte-identical and can be prompt-cached) and is not a sequential counter. Whoever sees a token — the AI provider included — cannot recompute it for a guessed value: the printed salt reveals nothing about the id key. (Earlier releases derived the id from the value and the printed salt, which let a token be checked against a guess.)

Including the entity type in the token lets the AI model respond semantically — for example, it can say "I'll contact you at your email address" rather than echoing the opaque token verbatim.

The model is told how to treat a token. Whenever masking is active for a turn in the chat, the system prompt the gateway composes carries a short "Masked personal data" rule: a token stands for one real value the model cannot see, the app puts the value back before the user reads the answer, so the model copies the token character for character wherever that value belongs, never writes a made-up name or a generic stand-in such as [Name] instead, and does not refuse or comment on the masking. An instruction made of tokens ("change X to Y") is carried out by writing Y's token where X stood. The rule is present whenever the masking layer is on for the turn, also when this turn's text contains nothing to mask, and absent when the turn is not masked (for example a turn that runs only on local models). It is a request to the model, not a filter: a model can still ignore it, and a name it invents in place of a token is shown as written, because it cannot be told from a real answer. The rule is added to a conversation turn (the request carries a non-empty x-aig-conv-id header, has a messages array, and belongs to a signed-in user) and to every run of an agent on a gateway whose masking layer is on: on an agent run it is placed before the agent's own instructions, so a structured-output directive still follows the rule and the instructions, and a run never carries it twice. A plain API call that is neither (for example a request to the chat completions endpoint without a conversation id) does not get it, and neither does an agent run on a gateway without masking. Earlier assistant answers in the history are masked like the user's own messages, also with the default skip_system_messages: true, which skips only the system role. A conversation stores each answer with the real values restored, so the same value in the user message and in the assistant answer becomes the same token, and the model never sees the real name next to a token. A value that appears only in the history is masked on every turn that replays it, and is reported as detected on each of those turns.

Salts, identifiers and reason tags derive from the active master key only, so after a master-key rotation new requests carry different tokens than before; restoring tokens inside one request is exact, and a conversation started before the rotation simply continues under the new tokens. The same original value appearing multiple times in a single request always maps to the same token. On the response side, all occurrences of a given token are restored to the same original value. A token the model writes without its square brackets (MYRA-REDACT-{TYPE}:SALT:N) is restored the same way when it belongs to the conversation; an unknown one is replaced by its typed placeholder.

Restore is one pass, one level. The response is restored in a single left-to-right sweep over the masked text: each token is looked up in the request's own token map and replaced once, and a restored value is never rescanned. A token that sits inside another token's value (which the gateway does not mint deliberately — it can only arise when a token from an earlier turn of the same conversation is pasted into a value that is then detected) is therefore rendered as a typed placeholder (for example [name]) rather than restored, deterministically. On the buffered response the Custom PII detector restores its own [MYRA-CUSTOM:…] tokens in a first pass and PII Protector restores everything in a second, so a PII Protector token inside a keyword's value is restored by that second pass. The restore cost is linear in the response size plus the number of masked values — never their product. A token the model mangled or that was cut off before its closing ] (for example by max_tokens) cannot be restored and is rendered as a typed placeholder too. A non-streamed answer is cleaned value by value on its decoded text (a tool call's arguments included), so the cleanup never changes the answer's JSON structure; an answer that is not valid JSON (for example one cut off mid-document) is cleaned value by value as far as its values can be found, and the text between them too. The same token rule is applied to the non-streamed answer, to each chunk of a streamed answer, at the stream's end and to the stored message: a mangled token whose closing ] follows within 96 bytes (with no other [ or " before it) is replaced up to that ]; a token without one — typically cut off by max_tokens — loses only its own characters, and the text after it stays. Only the two token families ([MYRA-REDACT-… and [MYRA-CUSTOM:…) and the file-name stand-ins (see File names below — an unknown MYRA-FILE-<16 hex>, in any letter case, or a shorter run of hex digits cut off at the end of the text, becomes [file]) are cleaned — ordinary bracketed text such as [Myra-Security] or [MYRA-CUSTOMER_ID] is left as it is.

What this does not guarantee:

  • That the stored message is byte-identical to what was shown. The answer and the stored message are cleaned separately. A stray token fragment directly next to a real token can therefore end up differently in the two, and can swallow part of the restored value next to it. A bare token prefix with no salt or id (such as [MYRA-RED right before a quote) may also be cleaned in one and kept in the other.
  • JSON escapes inside a token on a raw stream. A native stream whose provider response is not labelled text/event-stream (see the next point) is scanned as written, without decoding JSON escapes. A token whose own characters the model wrote as a JSON escape (for example \u005bMYRA-…]) is therefore not recognised as a token on such a raw stream; a bare MYRA-… token inside such an escaped bracket is still cleaned. Models do not escape plain ASCII in practice. The same text restored as a whole decoded answer is cleaned by value.
  • Native (passthrough) streams. Every native stream the provider sends as server-sent events (text/event-stream) is restored per stream event, on the decoded text, holding back a partial token per block exactly like the OpenAI-compatible chat API. That covers the native Anthropic Messages stream (/anthropic/v1/messages, also what the Playground's Claude panel uses: text_delta, thinking_delta, input_json_delta per content block); the OpenAI-dialect streams of every provider (OpenAI, Azure, Mistral, Groq, …) — the legacy completions passthrough /<provider>/v1/completions (choices[].text) and, wherever a native stream carries them, the chat chunk fields (choices[].delta.content including Mistral's content-chunk arrays, reasoning_content, reasoning, refusal, audio.transcript, tool_calls[].function.arguments, function_call.arguments), per choice and tool call (a provider route's …/chat/completions is the OpenAI-compatible chat API itself); the OpenAI Responses event shape (the text, refusal, reasoning, transcript and tool-input deltas, per item and content part); the Gemini / Vertex stream (candidates[].content.parts[].text per candidate, thought text apart); and the Cohere v2 stream (content, tool-plan and tool-call deltas per index). A token the model streams across several events is restored. A block's held remainder is sent before the event that ends the block, as one more delta of that block, or appended to the ending chunk's own text when that chunk carries text of the block (see the API reference for the exact shapes). Every other string of an event is cleaned per event, and also loses a trailing [, [M, [MY, [MYR or [MYRA: text in a field or event shape not listed here (for example a choices that is not an array, a delta type the gateway does not read, a text field that is not a string, or OpenRouter's reasoning_details), and every string of an event whose data is JSON-like but not a decodable JSON object (a JSON array or string, or nesting deeper than the decoder accepts). Only the known events that carry whole strings (such as a .done with the full text or content_block_stop) keep the plain per-event cleanup; an event that opens a block (such as message_start, content_block_start or response.output_item.added) does not, because a client appends the block's deltas to its text. The text of an opener that the block's deltas continue (such as a content_block_start text block's text, a Responses content part's text, or a Cohere content-start's text) is held back like a delta, so a token split between the opener and the block's first delta reaches the client restored; if the block's first delta does not follow, that held part is cleaned like the rest of the opener. The exact list is in the API reference. Long integers in an event the gateway re-encodes (a 16+ digit sequence_number or id) are sent exactly as the provider wrote them. A token split across two such events therefore never shows its [MYRA- start: a first part long enough to be recognised becomes a placeholder, a shorter one is removed, and the rest of the token can still arrive as written, without its start. A legitimate value in such an event that ends in one of these characters loses them. The stored message shows the restored value. When the request masked PII, the log probabilities of a native stream (logprobs, Gemini logprobsResult, where the provider sends them) are emptied: they repeat the masked text token by token and cannot be restored truthfully (in a payload too deeply nested to decode, their strings are only cut like the others). What remains cleaned per event only, so a token split across two events can reach the client partly or wholly as written: a data: payload that is not JSON at all, and every native stream whose provider response is not labelled text/event-stream (cleaned on its raw bytes). The real values are never sent in these cases — only the gateway's placeholder token. On any stream, a held token prefix released after 96 bytes without its ] can reach a streamed client partly as written.

Deduplication and overlapping spans

Deduplication: when the same PII value appears multiple times in the request, all occurrences are replaced with the same token and all are restored identically in the response.

Overlapping spans: when the detection engine identifies overlapping entity spans (for example, a name inside an email address detected as both EMAIL and PERSON, or a numeric string matching both CREDIT_CARD and IBAN), the overlapping spans are merged and their entire combined range — the union — is masked as a single token. No character covered by any detected span is ever left unmasked, even where a lower-confidence span extends past a higher-confidence one. The token's label is taken from the highest-confidence span in the group.

Spans over a redaction token: a detected span never re-masks a redaction token this request already produced — its own [MYRA-REDACT-…] from an earlier detector or the retry, or the Custom PII detector's [MYRA-CUSTOM:…] (which runs first). The detection engine does tag token text (the id part of a token can score as an e-mail address), and re-masking it would mint a token whose value is another token, so the original value could never be restored. Every span is therefore clipped to the prose around the request's own tokens before it is masked: a span that straddles a token masks the text on either side of it as two tokens (clip-created whitespace edges trimmed), a span that lies entirely on a token masks nothing, and a keyword the Custom PII detector protected round-trips intact through a later PII Protector scan (the NLP PII Detector's scrub action is governed separately). The protected set is the request's own mask record, never the shape of the text — a caller-typed [MYRA-…] string is ordinary content and is masked like any other (the same rule as the German-ID exemption below). A partially scanned tool result keeps a token whole even when the failed chunk's boundary fell inside it: the placeholder covers the un-scanned prose, the token stays restorable.


fail_open behaviour

fail_open Sidecar unavailable
true (default) Request passes through without tokenisation
false Request is blocked — the chat shows the "Safety check temporarily unavailable" bubble with a Try again action; an attachment on the blocked request stays in that turn and is re-sent by Try again (see Guardrail blocks in the chat)

Workflow trigger content (an email body or attachment, a form upload) is masked by this detector before it is stored in the run; there a sidecar outage always withholds the content, whatever fail_open says — see Workflow trigger content.


PII in the web-search query

The model-generated web-search query is not pseudonymized. Detected entities, protected terms (personal and custom_pii keywords) and any redaction placeholder in it are removed before the query leaves, and a query with nothing meaningful left is not sent (the model gets a "search skipped" result). See Personal data in the search query.

PII in tool results (RAG, file search, web, fetched URLs)

When the gateway runs server-side tools, the text a tool returns — a knowledge-base chunk, a file read, a fetched web page, a search result — is untrusted input and can itself contain PII. Before that text is handed back to the model on the next step of the turn, PII Protector scans it with the same NLP detection and reversible tokenisation used on the request body: a name, address, or German structured ID that appears only inside a fetched document is tokenised (and restored in the final answer) exactly as if the user had typed it. No extra configuration is required — any enabled pii_protector detector covers tool results automatically. Large documents are split into chunks and scanned incrementally within one wall-clock budget (the total-scan latency ceiling), so a big RAG result cannot time out the turn.

Per-chunk survival. A large tool result is scanned chunk by chunk. The chunks that scan successfully are tokenised and kept; if a chunk cannot be scanned — a transient engine error, or the budget runs out before that chunk is reached — only that chunk is withheld in place, replaced by [content withheld: PII scan unavailable], while the rest of the result survives. This means a large RAG turn no longer drops all of its grounding when the PII engine is slow: it keeps as much retrieved content as the budget and the engine can cover. Fail-closed is preserved per chunk — a withheld chunk's bytes are dropped, never restored, so no un-scanned tool text reaches the model.

⚠️ Fail-closed by default. Unlike the request phase (which defaults to fail_open: true), the tool-result scan fails closed: if the PII engine is unavailable while scanning, the affected content is withheld — a single failed chunk becomes [content withheld: PII scan unavailable], and a result whose every chunk fails (or a result carrying malformed UTF-8, where a chunk cannot be placed precisely) is withheld whole as [tool result withheld: PII scan unavailable]. Either way, no un-scanned tool text reaches the model. Set fail_open: true on the detector to instead pass the tool result through on an engine outage (logged, and recorded on the request as a guardrail gap). Only do this when NLP-detected tool-result PII (names, addresses) is acceptable to leak under degradation — and note that under a PII mandate (a pii_mandatory project, a tenant with masking enforced) the flag does not win at this seam: the result is withheld regardless, except on a wholly-local model leg where nothing leaves the estate.

German structured IDs and Danish identifiers are still masked even under fail_open. The structured-ID recognizers (de_recognizers — Steuer-ID, USt-IdNr, KV-Nr, SV-Nr, Personalausweis; dk_recognizers — CPR, the labelled Danish identifiers and Danish phone numbers) are pure pattern checks and have no dependency on the NLP engine, so they still run offline when the engine is down. A result that fails the engine scan is forwarded with those IDs masked (only the NLP-only PII the engine would have caught leaks). This holds whether a single chunk or the whole result failed.

fail_open PII engine unavailable while scanning a tool result
false (default for tool results) Un-scannable chunks are withheld (placeholder); the scannable content survives; the turn proceeds
true, no PII mandate The tool result is forwarded on outage (logged, and the request records guardrail_degraded / pii_scan_degraded / guardrail_error) — but the offline recognizers still mask: German structured IDs (de_recognizers), Danish identifiers and phone numbers (dk_recognizers), a labelled date of birth (DATE_OF_BIRTH, when dob_recognizer is on) and German and Danish age expressions (DE_AGE, when the request is handled as German); only NLP-detected PII (names/addresses) leaks
true, under a PII mandate Withheld exactly as false (the mandate outranks the flag); the request records pii_mandate_masker_unavailable. A result bound for a wholly-local model leg is exempt (forwarded, not a gap)

Paged web pages (fetch_url / agentic_fetch / web-search auto-fetch). A long web or text page reaches the model in windows of about 6000 bytes. Each window is masked together with about 256 bytes of the page text on each side: the engine analyses the surrounding text, but only the window is returned. An identifier that crosses a window edge — a name, IBAN, phone number, card number or e-mail address cut by the window's start or end, whatever offset was asked for — is therefore recognised whole and its visible part is tokenised (the token restores to that part in the final answer). This pass runs before the result is handed on, and the normal tool-result scan still runs afterwards (it can only mask more), so a paged window costs one extra analysis call per analysing detector (for an agentic_fetch part a second edge-only pass can follow — on an external inner model when the outer scan runs a masker the inner request does not, and always on a local inner model with an external outer leg — plus the inner request's own scan; an NLP PII Detector block in the inner request adds its own pre-check call); each pass has its own scan time budget (the PII Protector's tool-result budget; an NLP PII Detector its own per-call budget), and the tool loop's overall time limit bounds the turn (the web-search auto-fetch shares one budget across all the pages it fetches for one search). This pass is the only scan that sees the surrounding text, so if the engine is unavailable during it the window is withheld unless the detector is explicitly fail_open: true and no PII mandate is in force — for every masker type, including an NLP PII Detector in scrub mode (which otherwise passes tool results through on an outage); a masker that fails internally withholds the window even with fail_open: true. On a wholly-local model leg (nothing leaves the estate) the normal tool-result outage rules apply instead. Withheld: fetch_url returns [tool result withheld: PII scan unavailable] for that window (paging stops); agentic_fetch reports the part as failed with its next_offset (the inner model is not called); the web-search auto-fetch shows the placeholder instead of that page. A fail_open: true forward in this pass is recorded as a gap (guardrail_degraded / pii_scan_degraded; the server log names the phase tool_result_window) even if the later scan succeeds, because that scan has no page context. Limit: an identifier longer than 256 bytes that crosses an edge can still show a fragment.

Gateway cuts: tool-result cap, document caps, knowledge pages, program output. The gateway also cuts tool text BEFORE the tool-result scan sees it: a tool result is capped at 80 KB (a code-interpreter result keeps its first and last part), a fetched document or web page is cut at the per-call text budget (10240 bytes for fetch_url, agentic_fetch and the web-search auto-fetch), an uploaded workflow file and a workflow connector result at 20 KB, a knowledge read or search serves selected pages (the pages around them are left out, and a page label is inserted between pages), and a program's output stream is cut at 64 KB; the video service's error message that create_video relays to the model is cut at 200 bytes; a search_knowledge query echoed into its result is cut at 1,000 characters; the excerpt of the current file an edit_file error shows when a quoted passage is not found is cut at 1,200 bytes (a refused cut shows no excerpt); a read_file partial read (lines) serves a line range of the file. At every such cut the identifier that crosses it is masked together with up to 256 bytes of the dropped text — the same rule as for a paged window: only the text next to the cut is analysed (about 512 bytes per cut side — one extra analysis call per side for each NLP masking detector, with a budget of its own of at most 15 seconds per cutting step — the 80 KB cap of a result, one agentic_fetch document, the two output streams of one program run; a workflow document's extraction cut and its re-cut after masking have one each; the web-search auto-fetch shares one budget across all its pages' cuts and window passes; a knowledge read masks both sides of every page it serves or labels within the 80 KB result, i.e. one to two calls per page boundary — identical edge texts are answered from the analysis cache — run up to four at a time under one shared budget: about 0.3–1.5 s extra for a document with 10–60 page boundaries in the result, more for one with many very short pages), the rest of the result is scanned as before, and an identifier crossing the cut has its visible part tokenised instead of reaching the model as an unrecognised fragment. The operator regex / keyword detectors and Custom PII keywords are applied the same way at the cut. If the engine is unavailable during a cut pass, the window rule above applies (the result is withheld unless the detector is explicitly fail_open: true outside a mandate — also for an NLP PII Detector in scrub mode): the tool result becomes [tool result withheld: PII scan unavailable] (a knowledge read or search is withheld whole, and its page citations are dropped; a workflow file is stored as the withheld placeholder). A regex / keyword block crossing a cut refuses the result like any other block on a tool result (see Which detectors cover tool results). Program output is the exception to "the result": a refused cut of a code-interpreter output stream replaces only that stream by the placeholder — the other stream and the files the program produced are still delivered (see Code interpreter); a refused cut of the video service's error message relays none of it — the model gets the fixed sentence asking it to use the default model, size and length; a refused cut of a search_knowledge query leaves the query out of the result heading. A result that is not cut costs nothing extra; a gateway with no masking detector skips the pass entirely. Limits (the text beyond the cut never reaches the gateway, so there is no context to mask with): an explicit page range of a fetched PDF (pages), the page limit of an extraction (a text budget of 512 KB for a chat attachment, 200 pages for a directly opened document; 50 pages for the web-search auto-fetch), a dense OCR page cut by the extractor (and text on the boundary of two OCR strips), a knowledge file that was only partially extracted, snippets a web-search provider has already shortened, and output an MCP server or other connector shortens itself before answering. An identifier longer than 256 bytes that crosses a cut can still show a fragment. A workflow persistence cut (an e-mail body or attachment text kept to 20 KB on a masking gateway, a connector result, a form file) is masked with the gateway's detectors; an e-mail body, an attachment and a form file also with the workflow owner's personal keywords and role detectors (a connector result: the gateway's own only — the agent step applies the owner's to the kept text). Content stored before this change (chat history with an upload's cut text, bridge history) keeps whatever fragment it was stored with.

Workflow connector results (JSON text). A Connector node stores the connector's result as JSON text, in which a line break, tab or carriage return inside a string is written \n, \t or \r. The persistence masking reads those as the control characters they stand for, so an identifier directly after one (an IBAN after \n, an e-mail after \t, a phone number after \r) is masked the same as after a space. The stored result keeps its JSON structure and line breaks. A bare JSON number that is masked becomes a quoted string holding the placeholder. If the masked text cannot be shown to be valid JSON, the whole result is withheld instead of stored. That includes a mask that runs past a bare JSON number into the next token (or starts on the whitespace before it): it cannot be proven safe, so the whole result is withheld. The gateway applies this to the connector-result cut of a workflow only; a result of an agent's tool call in a chat is not covered by it yet.

Conversation summaries. When a long conversation is compacted through the summarise endpoint, every message longer than 16,000 bytes is shortened to its first 8,000 and last 6,000 bytes before the request-phase scan sees the summary prompt. Both cuts are masked the same way — the identifier crossing a cut is analysed together with up to 256 bytes of the removed middle, with the gateway's request-phase detectors (the ones the summary prompt itself is then scanned with), all cuts of one summary in one batch. If a cut cannot be masked the summary is not sent: an unavailable detector answers 503 guardrail_unavailable (retry), a block detector matching across a cut answers guardrail_blocked. A summary on a local (Myra-hosted) model is not masked, as everywhere else.

Cuts outside a request: chat uploads, chat-bridge messages. Two more places cut user content before the request that carries it is scanned, and have no request of their own: the text of a chat attachment (cut at the 512 KB inline limit, a data file's sample at 64 KB) and a Slack / Teams / Mattermost message (cut to its first 16,384 characters when it is longer than 16 KiB). Both are masked at the cut the same way — the identifier crossing it is analysed with up to 256 bytes of the dropped text — with the detectors of the request that will carry the text: for an upload, the gateway's request-phase detectors plus the uploader's personal keywords and role detectors, under the mandate of the conversation / project the upload names (the in-app composer sends it; an API caller that sends no policy reference gets the tenant-level mandate only); for a bridge message, the agent run's detectors (the connection's gateway, the agent owner's keywords and role detectors, the mandate of the agent's knowledge areas). The provider of that later request is not known at the cut, so the cut is masked even where the turn later runs on a local (Myra-hosted) model — at most the one value at the cut, never the rest of the text. A token minted at the cut is not restorable (there is no request token map yet): the model, the reply and the stored turn see a placeholder for that one value. If the cut cannot be masked, the content is refused instead of sent: the upload answers 503 guardrail_unavailable (retry) or 400 guardrail_blocked, the bridge answers that the message is too long and could not be shortened safely. Only the error line in the server log and the model-error triage row record such an outage — the cut runs before any request log row exists.

Names and labels are replaced, never cut. A value that is only a hint is not shortened at all: an untrusted-content frame label over 512 bytes (a fetched URL, a search query, a file name) becomes source label omitted (too long) — the full value is in the result body or is the model's own tool argument; a knowledge section label over 508 bytes (for example the first row of a CSV without a header row) is left out of the page anchor and the citation (a stored label of 509–512 bytes — the old cut — is left out as well); a convert_document output name whose stem exceeds 242 bytes becomes slides.<format> / document.<format>; an uploaded form file or e-mail attachment name over 255 bytes is stored as file.<its extension>; an e-mail trigger header (from, subject, date) over 1,000 characters is stored as (header omitted: longer than 1000 characters); in the structure summary of an uploaded data file a column name over 60 characters becomes (column N), a sheet name over 100 characters (unnamed), a column with a value over 40 characters loses its value list, and columns that do not fit the summary are counted instead of cut.

Never served: the end of a truncated knowledge document. A knowledge document whose extracted text exceeds the storage limit (about 7.5 MB) is stored cut and without page segments; such a document is not chunked for search, and reading it returns only its first 80 KB. Its stored end — the cut — never reaches a model, so there is nothing to mask there.

agentic_fetch parts: every edge-sensitive detector of the inner request. A part bound for the inner model is pre-checked with exactly the detectors the inner leg's request phase runs (including the user's personal and role keywords). Besides the PII maskers above, that pre-check also covers the operator's regex / keyword detectors with action: "scrub" and the refusing detectors — regex, keyword and the NLP PII Detector with action: "block": a regex / keyword match that crosses or touches a window edge, and an NLP PII entity that crosses one (a detection strictly inside the window is left to the inner request phase, which records it as usual; touching matters for regex / keyword because the inner prompt puts the window right after a line break). They match the page text exactly as the request phase does (over the JSON-encoded body), so the pre-check never matches more than the inner request phase would on the whole identifier. A scrub replaces the visible part with the detector's placeholder; a refusal fails the part exactly as an inner-request block does (next_offset kept, the inner model is not called; the detector is listed in detectors_fired, the outer request is not marked blocked). On a first-party local inner model (whose request phase masks nothing) only the refusing detectors run. An NLP PII Detector block that cannot reach its engine during this pre-check withholds the part unless it is explicitly fail_open: true and no PII mandate is in force; on a local inner model it withholds only when it is explicitly fail_open: false (the inner request phase's own rule). An analyzer answer whose entity cannot be placed withholds the part.

Diagnosing withholds on large-RAG turns. When a turn returns large results against a slow PII engine, some content can be withheld. A whole-result withhold (every chunk of a result failed) logs a cause; per-chunk withholds are counted separately. A one-line [tool_result_scrub_summary] results=N scanned=S withheld=W chunks_withheld=C scan_ms=T budget_ms=B is emitted per turn (scan_ms near budget_ms = the turn spent the whole budget against a slow engine): withheld=W counts whole results dropped; chunks_withheld=C counts individual chunks dropped from results that otherwise survived.

cause Meaning Durable fix
analyzer_error This result's own PII-engine scan timed out / errored while budget remained — the engine is capacity-constrained on large payloads Size the PII (Presidio) analyzer (workers/CPU, read timeout) — an ops change; no gateway budget can make a slow analyzer fast
budget_exhausted The shared per-turn scan budget was already spent when this result was reached (an earlier detector on the same result, or earlier results, consumed it); for a presidio scrub detector, its own per-call analyzer budget ran out Increase the shared per-turn scan budget (a deployment setting), or (if one flaky result starved healthy ones) size the analyzer
anonymizer_error A presidio scrub detector's analyzer answered but the /anonymize call failed — the result was withheld because a PII mandate is in force Size / restore the anonymizer sidecar; the analyzer half is healthy

The per-turn budget bounds how long a turn will wait on the scan; it is a bound, not a cure for a chronically slow engine. Fail-closed is preserved throughout — withheld content is never emitted un-scanned regardless of cause.

💡 Note: On one tool result, detectors compose, mirroring the request phase: multiple pii_protector detectors each add their entity coverage (e.g. a German and an English detector — the second never re-masks the first's tokens; see spans over a redaction token), and an NLP PII Detector (action: "scrub") ordered before a pii_protector detector also composes — presidio anonymises what it catches, then pii_protector tokenises the residual it missed (so one result can be both <EMAIL> and [MYRA-REDACT-PERSON]). A presidio-scrub detector ordered after pii_protector also runs on a result pii_protector already tokenised and anonymises what pii_protector left (for example an entity type its thresholds ignore) — it never touches the [MYRA-REDACT-…] / [MYRA-CUSTOM:…] token bytes, so the tokens still restore. (Earlier releases skipped such a result, and the leftover reached the model.)

⚠️ Which detectors cover tool results. Tool-result scanning applies to pii_protector, the NLP PII Detector (action: "scrub") and the Custom PII Blacklist (keyword masking) — and, for the signed-in user, the same user-specific detectors their prompt gets: their personal PII keywords (PII rules, in the Account area) and the request-phase PII masking detectors their role adds (custom_pii, pii_protector, NLP PII Detector in scrub mode). A personal keyword inside a fetched page, file read, RAG chunk, MCP or web-search result is therefore tokenised before it reaches the model, exactly as in the prompt (it needs a PII layer — a PII detector on the gateway or one the user's role adds — as for the prompt). If the personal keywords cannot be loaded, the same rule as for the prompt applies (logged, keywords not applied for that request); if the detector list itself cannot be resolved, every tool result of that step is withheld. A role's jailbreak / prompt-injection detectors are not run on tool results.

Operator regex / keyword detectors (the gateway's and the role's) run on every tool result returned to the model, exactly as on the prompt: an enabled detector with a request / both target and action: "scrub" replaces each match with its placeholder; action: "block" replaces the whole result with [tool result withheld: blocked by a gateway guardrail] (the detector is listed in detectors_fired; the turn continues — the model is told the result was withheld). The gateway's detectors run before the NLP maskers (tier order, as on the prompt); a role's run after the gateway's detectors, as on the prompt. They match the result in the request's JSON form (whole-word and / rules as described for the Keyword and Regex detectors), and never rewrite a protection token. On a tool result the gateway framed itself (what a tool returns to the model), no detector rewrites that framing: the untrusted-content markers and, in a fetched page or document, the gateway lines above its ## Content of / ## Answer for line (the paging notice with next_offset, page-count and OCR notes) are left as written — the source name in the marker, the URL or file name after ## Content of and the content itself are scanned. Where a tool result is itself JSON, the keyword and regex detectors read it the way the request phase does: every string value that is itself a JSON document (also one nested inside another) is decoded and matched as a document of its own, so a keyword written as an escape (M\u00fcller, an escaped quote or backslash) is found and masked, and the result stays valid JSON. With scrub, a field name that matches is masked like any other text ({"Müller":1} becomes {"<X>":1}); a match on a number is masked as plain text, so that result is then no longer guaranteed to be valid JSON ({"card":4111111111111111} becomes {"card":<X>}); only a match the gateway cannot mask in place (a field name written with escapes, or a match that only a repeated decoding reveals) withholds that result instead of passing it on. A result whose string-encoded documents are nested more than 15 levels deep is withheld rather than passed unchecked, and so is a tool result that is only a JSON string (a whole document encoded as one string) whose match is spelled with escapes inside it - it is withheld, not masked. With block, any match at any level withholds the result. flag does nothing on a tool result. On a wholly-local model leg only block applies (as on the prompt, where input masking is skipped there). Content that a later request phase scans anyway — an agentic_fetch document (scanned by the inner request) and content persisted for a workflow (scanned when it is sent to a model) — is left to that phase.

⚠️ Provider-native search is out of scope. This covers tool results the gateway fetches (gateway-mediated web search, URL fetch, file/RAG reads, MCP tools). A request that uses a provider's own server-side search (e.g. Anthropic web_search, Mistral Conversations) is not tokenised: the result text originated at that provider and is re-injected to the same provider, so it is not a new egress the gateway can interpose on — and rewriting the provider's server_tool_use/tool_result pairing would break the provider's own contract. If tool-result PII masking is a hard requirement, disable provider-native search so fetching is gateway-mediated (where it is scrubbed).


Stored content in the system prompt (memories, profile, files, instructions)

On a chat turn the gateway composes the system prompt from stored content: the user's memories, the profile (preferred name, work area, personal style), the file list of the project or the chat, the project instructions, the organization policy and the task prompt of a prompt example. This composition happens after the request-phase guardrails have run, so — in earlier releases — none of it was scanned: a value stored there (an e-mail address in a memory, an IBAN in the project instructions) reached the AI provider in clear on every turn, even on a gateway with mandatory masking. That gap also existed in production releases before this change.

Every stored piece is now masked before it is composed — file names are replaced by stand-in names (see File names) — with the same detectors the request phase applies to the user's message (the gateway's detectors, your personal keywords, a role's extra detectors) and the same reversible tokens:

  • Data pieces — memories, the preferred name and work area, and the personal style (your own custom instructions) — are user content: every masking detector applies, your personal keywords included. The preferred name and work area are scanned inside the sentence the prompt renders them in ("The user's preferred name is …"), so a bare first name is recognised.
  • File names in the project / chat file list are never sent as stored: each is replaced by a per-conversation stand-in name and the file tools resolve it back on the gateway — see File names below.
  • Instruction pieces — project instructions, the organization policy and the task prompt of a prompt example the tenant configured (the built-in default examples are gateway text and are not scanned) — are system text and get exactly what a system prompt sent by a client gets: PII Protector masks them under a mandate or when the detector sets skip_system_messages: false; the NLP PII detector, regex and keyword detectors always apply; Custom PII keywords and personal keywords do not (they never scan system text).
  • Block detectors redact. A regex, keyword or NLP PII detector with action: "block" that matches stored text replaces the match (the detector's placeholder, or the entity type) instead of refusing the turn — stored text recurs in every later turn, so a refusal would lock the user, the project or the whole tenant out, while forwarding would bypass the block.
  • Restore. A token the model repeats from the system prompt is restored in the answer exactly like a token from the user's message (streamed and buffered, and in the stored message).
  • Prompt cache. The tokens of a value are stable for the turns of one conversation, so the masked system prompt is byte-identical from turn to turn and the provider's prompt cache keeps hitting. Tokens differ between conversations and between users, so a masked prompt is not shared across conversations.

File names (stand-in names)

A file name is user content the gateway composes into the request — and an NLP engine has no context to recognise a person in a bare name like Kündigung Müller.pdf. So on a gateway that masks personal data (any masking detector applies to the request, the model leg is not wholly local) the provider never sees a stored file name. It sees a stand-in name instead: MYRA-FILE- followed by 16 hexadecimal digits, plus the file's extension when it is a known file type (MYRA-FILE-0f3a9c1d07be4a21.pdf; an unknown "extension" such as Vertrag.Mueller is replaced along with the rest of the name, and a folder path is part of the name).

  • Where. The project / chat file list in the system prompt; everything the file tools return — read_file's labels, page anchors and its "not found" list of available files, search_knowledge's passage labels, convert_document's source and output names, code_interpreter's notes about the files it staged; the name inside a chat attachment's [Document: …] / [Image: …] / [File: …] marker (any file type, also in a temporary chat; a name the detectors already masked in part stays as the request phase left it); and a stored name with a known extension — of a file in the file list or attached to the chat — that appears as text in the conversation (an earlier answer that cited a file, your own "summarise Q3-plan.md", a compaction summary, and the workspace's own follow-up suggestions and chat titles, which re-send the answer) when it stands as a word of prose, as a quoted string (input_files=["Q3-plan.md"], {"file":"Q3-plan.md"}) or after the code sandbox's /input/ or /output/ folder — any other URL, path or query string (https://intranet/files/Q3-plan.md, a link target such as (sandbox:/mnt/data/Q3-plan.md)) is left as it was written, and a name without an extension ("Budget") is not looked for in prose, so ordinary words are never rewritten. A new name the model builds from a stored one (Q3-plan_v2.md) is replaced only once it is a stored file itself: an output that is only delivered in a temporary chat keeps its real name in later turns' text.
  • Stable. A file keeps its stand-in for the whole conversation (the system prompt stays byte-identical turn to turn, so the provider's prompt cache keeps hitting); another conversation uses different stand-ins. Renaming a file gives it a new stand-in. Without a conversation id (API calls, agent runs, the workspace's title and follow-up requests) the stand-ins are scoped to the request; in a conversation two people drive together, each person's turns use their own stand-ins. An agent run that pauses for a tool approval keeps its stand-ins when it resumes.
  • Tools keep working. read_file, write_file, edit_file (its messages echo the stand-in, never the stored name), code_interpreter (input_files and the /input/<name> path — the file is staged in the sandbox under the stand-in) and convert_document (the file and any image the HTML references) accept a stand-in and resolve it on the gateway to the stored file; the stored name is never echoed back to the model. A stored name the model copied from your own message still works. A MYRA-FILE-… name that is not one of this conversation's stand-ins is refused: read_file answers "File not found" with the list of available stand-ins (at most 200 of them, then how many more), the other tools return an error — nothing is ever stored under an invented stand-in. Writing to the stand-in of a file whose stored name write_file cannot address (a file in a folder, a name in a non-Latin script) is refused; a code_interpreter output named after such a file is saved under the file's own name without the folder, characters a file name cannot carry replaced by _ (never dropped); convert_document names its output after the source file's name, a folder separator replaced by _.
  • You see the real names. A stand-in the model writes is restored to the real name wherever the answer reaches you — the streamed and the buffered answer, the stored message, file cards and download names, the sources list, and the text of a file the model writes. A stand-in the gateway cannot map (invented or garbled by the model) is shown as [file].
  • Limits. A stand-in only says which file it is, not what it contains: to find the file that covers a topic the model searches the files (search_knowledge) or reads them. A file the model WRITES stores the real names of the files it mentions (you see them in it); when the model reads that file back later, those names are scanned like any tool result, not replaced by stand-ins. A name only the conversation's history still carries — a file since deleted or renamed — is no longer in the file space, so it is not replaced either (the detectors above still scan it). An API call without a conversation id gets no history replacement: the file list and the tools use stand-ins, but names in the messages the caller sends are its own text (scanned by the detectors). This includes a chat-bridge turn: its replayed history carries the gateway's own note on the files created in earlier replies, under their real names. The replacement in message text works within a bounded amount of work per request: in an extremely large request with a large file space (many file names of many different lengths), names in the messages processed last — which may include the newest message — can stay as written (logged as a warning; the detectors above still scan them). Up to 1,000 different file names in attachment markers ([File: …], [Document: …]) get a stand-in per request; a marker beyond that — or one whose name could not be a stored file name (over 255 characters, or with a control character) — shows attached file instead of its name (the name is not sent, and is not restored in the answer; logged as a warning), while other mentions of such a name in the message text stay as written (the detectors above still scan them). A name inside a stored memory or in the project / organization instructions is masked by the detectors above but not replaced by its stand-in. A model that re-cases a stand-in (myra-file-0F3A…) still reaches the file through the tools, but the answer shows [file] there. A binary file the sandbox produces (a Word or PDF document) keeps any stand-in the model wrote into it. A sub-agent's answer names its own files by their real names (it is the sub-agent's output; the parent's tool-result scan applies to it). A file the supervising model hands to a sub-agent by its stand-in is found by the sub-agent's file tools when it is in the sub-agent's own file space, and wherever the sub-agent's answer names that file (its name without the extension, as a whole word — also followed by another extension, quoted in code or JSON, or inside a path), the supervising model receives the stand-in again (you see the real name). A very short name (1.pdf) is therefore replaced wherever it stands as a word in that answer; a name the sub-agent writes in another letter case reaches the supervising model as written (the tool-result scan above still applies to it). The conversation summary the workspace builds for its own features masks the history with the detectors above but does not replace file names by stand-ins.

Sub-agent and connector labels

The user-authored labels the gateway adds to the tool list — a sub-agent's name and the first 300 bytes of its instructions (its tool description), an MCP connector's display name (in the "connectors attached" / "connectors unavailable" notices) — are masked through the same pass as the stored pieces: names as user content, instructions as system text. The tool descriptions and parameter schemas an MCP server publishes are the server's text, not your content, and are sent as the server wrote them (length- and shape-checked); the tool names themselves (agent__<slug>, the MCP tool name) are identifiers and are sent as they are. When the engine cannot scan a label, the turn is refused with a message that says the sub-agent or connector names could not be scanned.

Connector tool selection. When a turn carries many connector tools, the gateway may ask the Qwen tool selector on Myra's own EU fleet which tools fit the conversation (see MCP connectors API — tool selection). That call carries the recent turn text (the last three user messages and the last assistant message, at most 2 KiB) and the connector tool names and short descriptions. It runs after the request-phase masking, so it carries the text exactly as the chat model receives it: masked on a leg the gateway masks, unmasked on a wholly-local leg (see below). It never leaves Myra's infrastructure. When the gateway may not send requests to the Myra fleet — its approved-provider list leaves out myra, data residency, a disabled model, the organisation objects to Myra as a processor, or the gateway sends its Myra models to its own endpoint — the tools are ranked by keywords instead, with no selector call.

Engine outage — fail closed. Stored pieces follow the stricter tool-window rule: when the PII engine cannot scan a piece, it is sent unscanned only if the detector sets fail_open: true and no mandate applies (then only the offline structured-ID recognizers — German IDs, Danish CPR — mask it, and the gap is recorded as guardrail_degraded); otherwise the turn is refused, never sent with a piece missing or unscanned. The chat shows its usual "safety check temporarily unavailable — retry" message; an API caller's refusal text says the saved memories, profile or instructions could not be scanned. A piece whose scan only partly succeeded is treated the same way, and so is an NLP PII detector answer (block / scrub) carrying an entity whose position cannot be placed (PII Protector drops such a span, exactly as it does on the request phase). Note the consequence: on a gateway whose PII Protector does not set fail_open: true, an engine outage refuses every chat turn that carries a memory, a profile name or instructions — including turns whose own message the request phase would have forwarded on the same outage (the request phase defaults to fail_open: true). On a wholly-local model leg no masking detector runs (the data does not leave the platform); an operator block detector still redacts its matches there, and its outage follows the request phase's rule: the piece is forwarded unless the detector sets fail_open: false, and an entity whose position cannot be placed refuses the turn.

Limits.

  • Each piece is scanned on its own. A name the engine recognises in one memory is not looked for in another piece; a second spelling of it can stay readable there.
  • The memory block keeps its 16 KiB budget on the masked text; tokens are usually longer than the values they replace, so a user with many masked memories may see fewer of them in the prompt.
  • The assistant's white-label name and the runtime identity line (provider, model, gateway) are configuration, not personal data, and are not scanned.
  • request_log.meta.system_prompt_pii_masked records how many stored pieces a turn masked.

Photos and images

On a gateway with an active PII guardrail an image is never forwarded to the model as pixels: a raster cannot be masked. Instead, the gateway's on-premises vision model turns the image into text, namely the verbatim text it contains plus a description of what the picture shows, and that text is sent as part of your message. It is masked like any text you type, so a name or an email address visible in a photo is replaced by its placeholder before anything leaves the gateway. The chat tells you when the model received a description rather than the image; if the description service is unavailable, only the recognised text is sent and the chat says so. See Image description for the response fields.

Manual unmask (Unmask on Demand)

The pre-send PII preview lets a user selectively unmask a specific detected value — sending it to the model in the clear despite detection — when the automatic detector was wrong (for example, a product name mistaken for a person). Enforcement is entirely server-side; the client only expresses intent.

Preview response. The preview endpoint returns, alongside the masked text, a spans array of { token, type, value } for each [MYRA-REDACT-*] token, so the interface can show the original value behind each pill and offer a per-value unmask toggle. (Custom-keyword [MYRA-CUSTOM:…] tokens have no span and are not user-unmaskable.) The value is the caller's own submitted draft — the endpoint makes no upstream call and never logs it.

Under enforced masking the preview returns no values. Whenever masking is mandatory for the request — a project whose tier is pii_mandatory, a tenant with masking enforced, an agent-area PII mandate, or a fail-closed indeterminate tier (the same pii_mandate_in_force condition the send-time denial below uses) — the preview withholds the spans values entirely — spans is empty and the raw values appear nowhere in the response, while detected (the entity types and counts) still shows what was masked. The client is never the authz boundary: because a manual unmask would be denied server-side at send (below), the preview does not hand the caller material it could never use, so the raw value never reaches a client that lacks the permission — even one that ignores the interface's locked pills.

Carrying the choice. The chosen values ride a gateway-private request body field (never a header — a header would silently drop oversized JSON and corrupt non-Latin-1 values). The same field also carries the manual mask list (see below):

{ "messages": [ ... ], "x-aig-pii-overrides": { "unmask": ["Acme Foobar"], "mask": ["Project Zeus"] } }

The gateway strips this field from the request body at the dispatch chokepoint, unconditionally on every gateway — regardless of whether PII protection is active — so it is never forwarded to any provider. (The field is only interpreted on a gateway that runs PII protection, and is only emitted by the interface there; a gateway with no PII detector does not interpret it — but it is stripped before egress either way, so a client cannot smuggle it through to the model.)

The full field reference is in Inference - the x-aig-pii-overrides body field.

What is accepted / rejected (fail closed). The field is untrusted input, validated at the trust boundary — any deviation drops the override and the request is masked normally:

Rule Behaviour on violation
Must be an object with unmask = array of strings Non-object / wrong shape → ignored
Each entry is a non-empty string ≤ 512 bytes; at most 64 entries All or nothing: one entry that is not a string, is empty, is oversized, or is beyond the 64th voids the whole unmask list, so a malformed list never unmasks a part of what was asked. The privacy record marks the override malformed
An unmask is honoured only for a value the gateway actually detected and tokenised this request A forged / absent / mismatched value matches no token → stays masked
The value must be tokenised in the current message (the last user message for chat; the prompt for completions; a string input; the last user input item of a Responses input; an embeddings input that is an array of plain strings counts as current in full — see Inference API) A value that appears only in earlier messages, or only in a tool result, stays masked. Once honoured, the value is restored in the earlier messages' text too, so the model never sees a placeholder for one real value; tool results and tool-call arguments keep their placeholders
The choice binds the turn's own request only The gateway's nested steps (conversation summaries, reading a fetched web page) re-scan other text on the same request: they never unmask, not even a value the turn itself honoured, so a summary or a fetched page keeps every value masked. Earlier content is never unmasked on their account
The value is spliced back exactly as tokenised A different value can never be substituted
Name parts follow the full name When you unmask a full person name that the gateway masked in the current message (for example Rumen Radev), a separate PERSON value that is a whole, contiguous run of that name's words — Radev or Rumen — is restored as well, in your own text fields only. Mette Nielsen follows Mette Kjaergaard Nielsen only when the words are adjacent: Mette Kjaergaard does, Mette Nielsen does not. Lookalikes (Rad, Radeva, RADEV) and a part that is as long as the name stay masked. Unmasking only the part never restores the full name, and a part is never itself a parent. A value of another type that equals a part (a LOCATION "Sofia" inside the person "Sofia Radeva") stays masked. The audit event's count includes the parts and its parts field says how many there were; a value already unmasked earlier in the same request never gets a second event, and a failed audit write reveals neither the name nor its parts. Accepted cost: another person in the same request's text who has the same surname or first name is sent unmasked too. Tool results and tool-call arguments keep their placeholders

Policy override is not possible. On a project whose tier is pii_mandatory, manual unmask is denied outright — masking is enforced server-side and a per-request field cannot weaken it. The denied attempt is logged and counted; no PII leaves masked.

Audit. Every honoured unmask writes one audit event (action: pii.unmask) recording the entity types and count (the number of distinct values honoured) only — never the raw value. The unmask is applied only after its audit event is written: if the event cannot be written, the values stay masked for that turn (the request is still forwarded, scrubbed, and an error is logged and counted). Rarely the event can over-record: a turn that was unmasked and then blocked at pii_reencode_failed still has its row. Masking telemetry is left intact, so a fully-unmasked turn still reports PII as active to downstream delivery gates. The PII masked chip on the reply (pii_masked_event) lists only the entity types that are still masked: a type whose every value you unmasked is left off it. Its optional source_types field (see Inference API) names the listed types that are masked only in sources — tool results and tool-call data, search results and queries, fetched pages, file and knowledge reads, composed instructions and memory — and no longer in your own text; the chip shows them on a separate Masked in sources line. On a wholly-local model leg your text is not masked, so everything masked on that turn (for example an address in a web-search query) is a source type. A type that is masked in several places is listed under the type's first-minted placeholder, so a value present both in your text and in a source counts as masked in your text. The counts are the distinct values still masked anywhere on the turn: they include the source-only values, and a value you sent unmasked is not counted unless it is still masked in a source.

Manual mask (Mask on Demand)

The pre-send PII preview also lets a user select undetected sensitive text — a project code name, an internal identifier the detectors do not recognise — and mask it before the message leaves the gateway. The user selects the text in the preview and the chosen substrings ride the same gateway-private body field, under mask:

{ "messages": [ ... ], "x-aig-pii-overrides": { "mask": ["Project Zeus"] } }

Additive and fail-closed. A manual mask only ever adds redaction of the caller's own draft text, so — unlike unmask — it is honoured on every tier, including pii_mandatory. A masked value is also masked in the content the gateway adds to the same request — tool results and the stored pieces of the system prompt — wherever PII Protector scans that content (not, for example, in instructions off-mandate without skip_system_messages: false, nor on a gateway without PII Protector). An unmask stays scoped to the caller's own text. The selected spans are tokenised in the same single pass as automatic detection (they become [MYRA-REDACT-MANUAL:…] tokens). Internally they carry the lowest span priority, so a manual selection can never displace or reduce an automatic detection: if a mask value overlaps a value the detector already found, the detection wins and stays fully masked. A mask value not present in the message is a no-op.

What is accepted / rejected (fail closed). Same validator as unmask: mask must be an array of strings, each ≤ 512 bytes, at most 64 entries; anything else is dropped and the message is masked normally. A value appearing in both mask and unmask is treated as a mask (the explicit protect wins). The field is stripped before the request reaches any provider.

Also applied to the automatic title and follow-up suggestions. After a turn, the chat sends two small requests of its own — the automatic conversation title and the follow-up suggestions — each carrying an excerpt of the same conversation text. They carry the manual mask list of the turn they follow in the same field, so a value you chose to mask for that message is masked on them too. The unmask list follows the same rule, so a value you sent unmasked is not turned back into a placeholder in the follow-up suggestions. The title request carries it only after the first message of a conversation, because that is the message the title is generated from; a title regenerated later does not. Like the overrides themselves, the lists apply to one send: the conversation history re-sent with later turns is masked by the automatic detectors only. These requests present the excerpt as a short transcript labelled User: / Assistant:; the labels are never masked as names (see the PERSON stop-list), while a real name inside the excerpt is masked as in the conversation. The pronoun rule (You: hello, Ich: hallo) and the sentence-start rule apply behind a label as they do at the start of a field, so User: You: hello keeps You readable.

Telemetry, not audit. Manual masks surface in the masking telemetry (the MANUAL entity type in the pii_masked event — a gateway-extension SSE frame, delivered only to a client that opted into the side channel, see Inference — what a plain client receives — and the X-AIG-PII-Active delivery gate) and are counted via the pii_mask_manual metric. They are not audited — masking more of one's own text is not a privileged action (unlike unmask, which is).

German structured IDs in spreadsheets and tables

Alongside the NLP engine, PII Protector runs gateway-side recognizers for German structured identifiers the NLP model scores too low to catch — Steuer-IdNr, USt-IdNr, Krankenversichertennummer, Sozialversicherungsnummer, and Personalausweisnummer — each validated by its official checksum. These are enabled per detector; names and email addresses remain the NLP engine's responsibility.

When an attached spreadsheet or table is analysed on a PII gateway, its extracted text reaches the guardrail as delimiter-joined rows (tab, ;, ,, or |; one row per line, first row the header). Because a bare 10–11-digit number passes a single-check-digit ID checksum by coincidence about 10% of the time, redacting such numbers cell-by-cell used to corrupt purely numeric columns (account numbers, counts, salaries) and produce wrong metrics. PII Protector now classifies each column instead:

Accepted (redacted):

  • A column whose header names a German ID (e.g. Steuer-ID, USt-IdNr, Versichertennummer, Personalausweis) is redacted in full — every cell, including one whose value is a typo or an odd format the checksum alone would miss (higher recall than per-cell matching).
  • A column whose values are predominantly valid IDs (an unlabelled ID column) is redacted in full.
  • Any value bearing a letter (USt-IdNr, KV/SV numbers, letter-form Personalausweis) and any ID embedded in free-text is always redacted, in any column.
  • With dk_recognizers on: a column whose header contains a CPR word (CPR, CPR-nr., Personnummer, …) is redacted in full once one cell is a recognised CPR, or when every value is a 9-/10-digit number (an Excel export that dropped the leading zero). A Danish CPR is never left in place by the numeric-column rule below, in any column: it is matched by shape and context, not by a coincidental check digit. (The block must be read as a table — every line with the same number of cells; see the API reference for the gaps.)
  • A key/value row that names a German ID has its values redacted even when the value column is otherwise numeric — e.g. Steuer-ID;86095742719 inside a Name;… / Tel;… / PLZ;… block, in tab-, ;-, |-, markdown- or comma-separated form. A checksum-valid ID with an ID label in any cell to its left in the same row is never left in place by the numeric-column rule, so separator cells (Steuer-ID;:;…), fillers (Steuer-ID;(privat);…), side-by-side records (Steuer-ID;<ID A>;<ID B>;<ID C>) and placeholders of another record (Steuer-ID;k. A.;<ID B>) are covered. The cost is accepted and reversible: in a row that names an ID, another checksum-valid number to the right of the label (for example a phone number in Steuer-ID;…;Tel;…) is masked too. Row labels use the column-header label vocabulary plus further Steuer-ID spellings that apply to rows only (Identifikations-Nr., Id.-Nr., Steuer-Ident-Nr., Steueridentnummer, SteuerIdNr, Steuerliche ID, TIN, Tax ID, TaxID, Taxpayer ID, Tax identification number): a row label affects one row, whereas a header label masks a whole column, and some of these words also occur in business column names. A non-breaking, thin or narrow space, a Unicode hyphen or an en/em dash pasted from Word or a PDF counts as its plain form (in headers too). With dk_recognizers on, a CPR word (CPR-nr.) labels its row the same way.
  • A header cell or row cell that is one of this request's own redaction tokens is never read as a label.

Preserved (not redacted):

  • A numeric non-ID column — one that is largely plain numbers with only occasional, coincidental checksum matches — is left intact so the model can compute correct metrics. Business-number headers (Personalnummer, Kontonummer, Mitarbeiter-Nr, Auftragsnummer, amount/rate columns) are treated as non-ID and survive; the same words in a key/value row (Konto;…, Kontonummer;…) do not label it either.

Residual and out of scope:

  • A genuine German ID sitting alone inside an otherwise-numeric, unlabelled column is indistinguishable from a coincidental match and is not redacted, so it can reach the model leg unmasked. This is a deliberate precision/recall trade-off accepted by the product owner: redacting every coincidental checksum match would corrupt legitimate numeric columns (account numbers, counts, salaries) and produce wrong metrics on every table. Give the column an ID header, or the row an ID label left of the value (above), to force redaction. The row rule does not cover a label to the right of the value (86095742719;Steuer-ID), a label outside the vocabulary, or a checksum-invalid value next to a label (a row label does not recover values the way a column header does). The exposure is limited to the model leg: tool, web-search, and MCP egress stay guarded — those paths run the free-text German-ID recognizer independently, so the same lone ID re-sent in a tool call or search query is still redacted. (Prose text — a Steuer-ID written in a sentence — is always redacted, unchanged.)
  • Tables from DOCX/PPTX (one cell per line) and space-aligned PDF tables are not column-detected; their content is scanned as prose (safe, but numeric columns there are not preserved).

What is exempt from the German-ID scan

Besides the column classification above, one other class of text is skipped: text that PII Protector has already masked on this request. A digit run that happens to sit inside a redaction token must not be masked a second time, or the value becomes unrecoverable when the answer is restored. The same rule governs the NER detections themselves — a detected span is clipped to the prose around the request's own tokens (see spans over a redaction token).

The exemption applies to the redaction tokens this request actually produced, and to nothing else. Text that merely looks like a redaction token is ordinary content and is scanned normally:

Input Scanned?
A redaction token this request produced, e.g. [MYRA-REDACT-DE_STEUER_ID:…] No — already masked
Text typed by the caller in the same shape, e.g. [MYRA- … ] Yes — it is ordinary content
A token from a different request, or a mangled/truncated one Yes — it cannot be restored, so it is not protected

This is why the exemption cannot be decided from the shape of the text: a caller controls what they type, so a shape-based rule would let anyone place a German ID beyond the scanner's reach. It is decided from the request's own mask record instead, which a caller cannot write to.


Comparison with NLP PII detector scrub

PII Protector NLP PII Detector (action: "scrub")
Request PII handling Tokenised (reversible) Replaced with <TYPE> placeholder (permanent)
Response restoration Yes (streaming and non-streaming) No
Model sees real PII Never on an external leg¹ Never on an external leg¹
Client sees real PII Yes No
Same-value deduplication Yes (same token per value) N/A (same label either way)
HTTP calls per request 1 (analyse only) 2 (analyse + anonymise)
Typical use case Model needs contextual continuity; client needs original values Audit or compliance logging; no restoration needed

¹ A wholly-local (Myra/EU) model leg is served unmasked — see Local model legs are not masked.


Limitations

💡 Note: Token restoration runs on both streaming and non-streaming responses. On the streaming path the gateway restores tokens incrementally on the wire, holding back any partial token that spans a chunk boundary so a half-token is never emitted; any token it cannot map back to a value is replaced with a neutral typed placeholder (e.g. [SSN]) rather than leaked. Remember the target requirement above: the response is only restored when the detector's target is "both".

⚠️ Caution (nested tool-call arguments): When a restored value containing a " or \ is echoed by the model inside tool_calls[].function.arguments — a JSON string whose body is itself JSON — the value is restored correctly and the response envelope stays valid on the OpenAI-compatible chat API, the SPA and every native stream sent as server-sent events: the native streams restore tool-call argument deltas (tool_calls[].function.arguments, Responses response.function_call_arguments.delta, Anthropic input_json_delta) JSON-escaped, so the reassembled arguments stay valid JSON. One documented residual remains on a native stream whose provider response is not labelled text/event-stream (it is cleaned on its raw bytes): an external client may receive such a value single-escaped inside the incrementally-streamed tool arguments, so the inner arguments string can be malformed for a client that re-parses it. The real PII is never leaked and the outer stream stays valid; use the OpenAI-compatible endpoint if a client re-parses tool-call arguments and needs the nested value intact.

💡 Note: If the model paraphrases rather than echoing a token verbatim, restoration is skipped for that value. Privacy is maintained (the model never saw the real PII), but the response does not contain the original value in that position.


Example configurations

Protect specific entity types

{
  "type": "pii_protector",
  "name": "protect-pii",
  "target": "both",
  "entities": ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER", "US_SSN"],
  "score_threshold": 0.75
}

Protect all entity types, blocking on sidecar failure

{
  "type": "pii_protector",
  "name": "protect-all-pii",
  "target": "both",
  "fail_open": false
}

Combine with regex pre-filtering

Use a regex guardrail (Tier 1) to block structured PCI data before PII Protector tokenises remaining PII. The regex block prevents card numbers from ever reaching the provider; PII Protector handles names, emails, and other values that benefit from restoration.

[
  {
    "type": "regex",
    "name": "block-card-data",
    "action": "block",
    "target": "request",
    "patterns": ["cc", "cvv", "iban"]
  },
  {
    "type": "pii_protector",
    "name": "tokenize-pii",
    "target": "both",
    "entities": ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER", "US_SSN", "LOCATION"]
  }
]

Exempt specific values from tokenisation

Use allow_list to prevent known non-PII values from being replaced with tokens. The analyzer applies it, so it exempts the analyzer's detections; a value that a gateway-side recognizer matches (a labelled Danish identifier, a Danish phone number with dk_recognizers, a date of birth) is still masked:

{
  "type": "pii_protector",
  "name": "protect-pii",
  "target": "both",
  "entities": ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER"],
  "allow_list": ["Myra Security", "Myra AI Workspace"],
  "allow_list_match": "exact"
}

Configuring PII Protector

Screenshot: PII Protector card in the Guardrail Builder PII Protector card — expanded view

Proceed as follows to configure PII Protector in the Guardrail Builder:

  1. Open the gateway page (Organisation › AI setup › Gateways) and its Guardrails & residency tab with the Guardrails card.
  2. Click on the PII Protector button.
    • A collapsed PII Protector card appears at the bottom of the list. A new card starts with the name pii-protect, target: "both", the Focused PII (low FP) entity set, score threshold 0.7 and Fail open selected.
  3. Click on the card to expand it.
  4. If required, change the name in the Name text field.
  5. If required, change the Entity types selection. Focused PII (low FP) selects the 14 low-FP types; All entities (~10-15% FP) removes the list, which tokenises all supported types; the card shows every listed type ticked, and clearing a tick asks for confirmation first because it turns All entities into a fixed list of the remaining types; adding a custom type while All entities is on asks the same way and then stores the listed types plus that one as a fixed list. The last selected entity type cannot be cleared; use All entities instead.
  6. If required, adjust the Score threshold field.
  7. If required, enter comma-separated values in the Allow list field to exempt known non-PII strings. They are compared as full strings; there is no Match mode control — the field's only non-default option was "partial", which the analyzer answers with HTTP 500, failing the detector open and forwarding the request unmasked. allow_list_match: "regex" remains available through the API.
  8. Clear the Skip system messages (system/developer role) check box if system and developer messages also require scanning.
  9. Clear the Fail open (pass requests through if Presidio is unreachable) check box if the sidecar must be a hard dependency.
  10. If required, select a value in the Language calibration list: Automatic, German, Danish or English. Choosing English asks for confirmation, because it removes the 0.6 floor for names and addresses (see language above).
  11. If required, select the German ID recognizers (Steuer-ID, KV-Nr, USt-IdNr, ...), Danish identifiers and phone numbers (CPR, CVR, account, passport, licence, phone) and Date of birth (labelled: geb., Geburtsdatum, DOB, ...) check boxes (de_recognizers, dk_recognizers, dob_recognizer). All three are off by default.
  12. Click on the Save Guardrails button.

-> PII Protector is saved and appears in the execution plan.


JSON number fields are not inspected

This detector reads text only. A value sent as a JSON number (a card number, an ID, a timestamp) is not inspected or changed by it. To catch or mask numeric fields use the regex or keyword guardrail, which scan the whole request body.

Pipeline position

PII Protector is Tier 2 — it makes an HTTP call to the Presidio sidecar. All Tier 1 guardrails (regex, keyword) run before any Tier 2 guardrail. Any regex or keyword scrubbing runs first; PII Protector tokenises whatever remains.


What a project PII mandate guarantees

In a project with the access tier PII protection required (pii_mandatory), a request to a third-party model has one of three outcomes:

  1. The gateway has a request-phase PII detector: the request is masked before it is sent.
  2. The gateway has none: the request is refused before dispatch with "This project requires PII protection, but the selected gateway has no PII filter configured. Use a PII-enabled gateway to continue." Nothing is sent.
  3. The request goes to a local Myra model first and fails over to an external provider: the failover leg is sent unmasked (see Local (Myra) model picks are never auto-masked). Use the Local only tier if no external failover is acceptable.

Tenant-enforced mandatory masking (not end-user-deactivatable)

A tenant can make PII masking mandatory for every user with the tenant flag pii_masking_enforced (see the configuration reference). A platform admin sets it with PATCH /admin/v1/tenants/{id} { "pii_masking_enforced": 1 } (or declaratively via the tenant_apply script); a tenant admin cannot change it. Each change is audited. When it is set:

  • The end user cannot disable masking. In chat, the Privacy toggle renders locked and read-only. The client hint that would request the unmasked route (hint_pii_preference) is ignored server-side.
  • Routing forces the PII gateway — except for a first-party (Myra) model pick. A request that would route to a non-masking gateway is redirected to its PII twin, unless the picked model is a first-party Myra model — see Local (Myra) model picks are never auto-masked below. For a non-Myra pick, if no masking gateway exists the request is rejected (pii_protection_required) rather than sent unmasked — fail-closed. A Myra pick is neither redirected nor rejected: it stays on the non-masking gateway and runs unmasked (an authorized, deliberate exception).
  • Manual unmask-on-demand is denied on an enforcing tenant.
  • All message roles are scanned. Enforcement forces a full-scope scan (system, assistant, and user messages) regardless of the detector's skip_system_messages setting (which on its own skips only the system role) — otherwise PII sitting in a system prompt or an org system_instruction would egress unmasked. The same holds for the stored instructions the gateway composes into the chat's system prompt — the project instructions, the organization policy and the tenant's own prompt-example task prompt — see Stored content in the system prompt. The per-detector toggle only widens the scan for a non-enforcing tenant; on an enforcing tenant the full-role scan is non-optional (fail-closed). The full-scope scan covers message text, tool results, the native top-level system prompt, and the arguments of a prior assistant tool call — tool_use.input (a tool_use input that is itself a string is masked as text), the OpenAI-compatible tool_calls[].function.arguments, the legacy function_call.arguments and a Responses function_call item — so PII the model re-sent inside a tool-call argument is masked like any other field. It also covers the non-message text carriers: prompt, input (a string, an array of strings, or the Responses-API array of message objects), and instructions. Under the default scope, system and developer message items inside a Responses-API input array are skipped like system messages; the function_call and function_call_output items are always scanned.

⚠️ Caution — not scanned. Anthropic thinking / redacted_thinking blocks are deliberately excluded. A thinking block is replayed with a cryptographic signature that covers its text, so tokenising it would invalidate the signature and the provider would reject the next turn; personal data in these blocks reaches the model.

Tool-call arguments are masked value by value. The arguments of an earlier assistant tool call (OpenAI-compatible tool_calls[].function.arguments, legacy function_call.arguments, a Responses function_call item) is a JSON document encoded inside a string. When it is one valid JSON object, each string value in it is masked and written back in place, so keys, numbers, whitespace and the escapes of unchanged values stay exactly as written and the tool call is still valid JSON. Arguments that are not valid JSON are masked as plain text. A system-role message is not scanned under the default scope. Object keys are not masked: personal data used as a key name ({"Klaus Mueller": 1}) reaches the model as written.

💡 Note: A request that carries its text in input — for example /v1/embeddings, or the Responses API — is tokenised like any other request. A client calling those endpoints through a PII gateway therefore receives vectors computed over the masked text, so vectors produced before and after this behaviour was added are not comparable.

Local model legs are not masked

This applies to every gateway (not only enforcing tenants), even a PII gateway, and regardless of the configured detectors:

  • A wholly-local (Myra/EU) model leg is never PII-masked — neither the model input nor the model output. When the effective egress set — the resolved primary provider and every failover fallback — is first-party local (myra/vllm), the PII-masking detectors (pii_protector, custom_pii, presidio action scrub, regex action scrub) are skipped in both the request and response phases (a target: "both" detector is skipped on each), and the inline-base64-media fail-closed block is skipped: the model receives the user's data intact and returns it intact. Masking a first-party leg protects nothing (the data never leaves Myra) and would silently corrupt extraction/analysis over the user's own text. This is not the same as the older "routing block" exemption. On a gateway that does run maskers, if any provider in the egress set is external (including a cross-vendor failover fallback), the request-phase masker still runs and the leg is masked (fail-closed) — this wholly-local skip keys on the whole egress chain. A Myra model PICK is governed by the separate, broader rule in Local (Myra) model picks are never auto-masked below: routing keeps it OFF the masking gateway entirely, so it is unmasked even when an external fallback exists — and may egress unmasked on failover.
  • Content-safety still applies on a local leg. Response-phase blocks (regex / presidio action block on target: response/both) still fire — the streamed answer is buffered so the block can run even though no request-phase masker forced buffering. Only the masking (scrub) detectors are skipped, never the blocks. Request-phase content-safety detectors (prompt_guard, keyword, regex/presidio action block) and tool egress (web search / URL fetch / MCP) are likewise unaffected.
  • The local-only exemption from an enforcing tenant's mandate is a MODEL-leg exemption. On a gateway whose every configured provider is first-party (local_only_gateway), an enforcing tenant's requests are exempt from the PII mandate on the model leg. The model-generated web-search query is not exempt: its bytes leave for the search provider, so it always gets the mandate floor — PERSON and LOCATION analysed and masked at the German 0.6 bar whatever the detector's language says — before it egresses, and the request records pii_egress_floor_forced_by_mandate. On a Presidio outage the query is withheld whatever the detector's fail_open says — the mandate binds at this seam even on this gateway and the request records pii_mandate_masker_unavailable; outside a mandate fail_open decides and a forward is recorded as a gap (see the fail_open row above). Two seams are governed by a separate refuse-on-structured-PII gate with no NER floor and are deliberately name-permissive: URLs handed to fetch_url, and MCP tool arguments — armed on a PII-active gateway or under a PII mandate from any source.
  • Agent-shaped runs always mask (both phases), regardless of model locality. An agent invoke, a scheduled prompt task and a delegated sub-agent deliver their output onward, so the whole leg is treated as third-party egress; the workflow copilot and a draft preview run through the same agent pipeline and are masked identically (a named ruling: one rule for every agent-shaped run). On a local-only gateway of an enforcing tenant this includes the PII-mandate floor (PERSON/LOCATION at the German 0.6 bar whatever the detector's language says, pii_floor_forced_by_mandate recorded) and the mandate's fail-closed refusal on a masker outage (pii_mandate_masker_unavailable), where a chat turn on the same gateway is exempt. A masked run emits X-AIG-PII-Active: 1, so the unattended delivery gate holds it (delivery_status: blocked_pii) exactly as on every other enforcing gateway. A masker-less such gateway still serves the invoke's primary leg (a first-party model pick is never hard-blocked); its inner legs (agentic fetch, mid-turn compaction) are refused.

The guarantee is egress-scoped: no unmasked PII leaves the gateway to an external model leg or in a web-search query. It is not a network-level DLP boundary — a user can still copy text out of the product manually — and it has a named residual on a local-only gateway of an enforcing tenant: there the model's context is unmasked (first-party leg), so a free-text name the model echoes into a fetch_url URL or an MCP tool argument is not caught (those gates refuse checksummed identifiers only). On every other enforcing gateway the name in the model's context is a token, so such an echo is refused. One further residual is tracked: a masker-less such gateway still serves an agent invoke's primary leg (the first-party carve-out, a deliberate product decision). The workflow persistence fence (form files, inbound email) binds the mandate on the strict leg — see the egress table below.

Local (Myra) model picks are never auto-masked

Authorized, deliberate exception. This is a deliberate product decision. A first-party Myra model pick never auto-enables PII masking — including on an enforcing (pii_masking_enforced) tenant or a pii_mandatory project. This is a compliance-relevant behavior that was chosen with full knowledge of its consequence; it is not a defect. An auditor reading a request that egressed unmasked to a third-party fallback under an active mandate should treat it as the expected behavior of this rule, traceable via the audit marker below.

Distinct from — and broader than — the wholly-local skip above: this rule is about which gateway the pick routes to, not about the masking-skip flag. When the user picks (or Auto resolves to, or a project/user default pins) a Myra model:

  • The pick is never redirected to a masking (PII) gateway. Under a mandate a non-Myra pick is routed to its PII twin; a Myra pick instead stays on the non-masking gateway and runs unmasked — the model input and output are left intact. This holds across every routing path (Auto default, an explicit model pick, a project- or user-pinned model, and the admin-config write-guard), so what you can save and what actually sends always agree.
  • Cloud failover egresses UNMASKED (accepted risk). If the gateway carries an external fallback and the Myra primary is unavailable, the request fails over to the external provider and egresses the body UNMASKED to that third party. The failover leg is intentionally not re-masked, and the turn is not blocked. This is the deliberate trade-off: the turn succeeds instead of failing, at the cost that — for a Myra pick that has to fail over — real PII may reach the external fallback provider under an active mandate.
  • The one retained exception (fail-closed): when the tenant's only gateway is a masking gateway (no non-masking gateway exists to route to), the Myra pick stays on the masking gateway — there is nowhere unmasked to route it. Masking then runs whenever the egress chain includes an external leg (the usual reason a masking gateway exists); a wholly-local Myra turn on it is still served unmasked by the wholly-local skip above (no third-party egress → nothing to protect).
  • Audit / observability. Every unmasked external egress under an active mandate is recorded on the request log: request_log.meta.pii_unmasked_egress_under_mandate = true, plus a [pii_unmasked_egress] gateway WARN log naming the external provider. In practice this fires exactly on the Myra-primary → external-fallback leg (an external primary or inner leg on a non-masking gateway under a mandate is hard-blocked before it can dispatch). The marker is observe-only — it never blocks, so the authorized egress stays fully traceable.

Rationale: a first-party Myra model runs inside Myra's EU perimeter, so masking its input corrupts the user's own data for no third-party-egress benefit; and the derailment the masking tokens caused on local turns (the model reasoning over [MYRA-REDACT-…] placeholders and asking cryptic clarifying questions) is removed. The failover-egress risk was weighed against turn availability and accepted.

Third-party egress — what is scrubbed vs blocked

Masking a value only works where the downstream sink tolerates a pseudonym. Where the real value is structurally required (a tool argument, a URL) a token would break the call, so the policy there is block, not scrub. On a PII-active gateway (one carrying a pii_protector) — or under a PII mandate from any source: an enforcing tenant, a pii_mandatory project, a forced agent invoke — every third-party egress point is covered:

Egress point Destination Policy
Model prompt / request external model Scrub (reversible tokenisation), or refuse the request if no request-phase masker under a mandate
Web-search query Brave / weather (US) Scrub the query under the mandate floor — including on a local-only gateway, whose model leg is exempt; under a mandate with no pii_protector to scrub with, the search is withheld. Decided by the Web search source's Personal data going to it cell: Mask (default) is this rule; Send as is sends the query with the real values (never under a mandate, where it reads as Mask); Block withholds a query carrying personal data on every gateway
Fetched document for the agentic inner agent the inner model (a model leg, not third-party egress) Under a mandate with no pii_protector, the document is withheld from a non-local inner model; a first-party local inner model is not a mandate case — except inside an agent-shaped run, whose inner leg is never treated as local, so the document is withheld there too
Web-page chunk for the agentic inner agent (agentic_fetch, one ~6000-byte window per call) the inner model (a model leg) Scrub each window in the inner leg's own request phase (skipped only for a first-party local inner model outside agent-shaped runs), after a pre-check of the window with ~256 bytes of surrounding page text — on an external inner model by every masker and edge-sensitive refuser of that request phase, on a local one by its refusers (and, when the outer model is external, an edge-only pass of the tool-result maskers) — so an identifier cut by any window edge — whatever offset the model chose — is masked or refused rather than shipped as a fragment (limit: identifiers longer than 256 bytes)
fetch_url / agentic-fetch URL arbitrary web host Block the fetch if the URL carries a protected structured identifier. Decided by the Web pages source's Personal data going to it cell: Mask (default) is this rule; Send as is restores masked values in the URL and skips the block (never under a mandate, where it reads as Mask); Block refuses such a URL on every gateway
MCP tool-call arguments the connector's MCP server Block the call if an argument carries a protected structured identifier. Decided by the connector's Personal data going to it cell: Mask (default) is this rule; Send as is (also a connector flagged a trusted EU/DPA subprocessor, trusted_subprocessor) restores masked values and skips the block, under a mandate it sends the arguments unchanged; Block refuses arguments carrying personal data on every gateway. A workflow Connector node keeps this rule with the trusted_subprocessor exemption
Tool and connector results the model (a model leg) Scrub on the tool-result scan. Decided by the source's Coming back cell: Don't mask skips the maskers for that source (never under a mandate); a page the agentic reader reads in windows is always masked
Conversation summarisation (compaction) external model Scrub before the summary leg egresses
Workflow persisted content — a form's uploaded file, an inbound email body / attachment the workflow run state (templated into every later step; a Deliver step emits it) Scrub under the mandate floor on the strict leg — a local-only gateway's model-leg exemption does not apply, and a masker outage withholds whatever fail_open says (with or without a mandate); under a mandate with no pii_protector the content is withheld. Read from the gateway's effective configuration (the tenant mandate folded in; coherent within an instance, bounded by config_cache_ttl across instances)
Image generation Myra-hosted EU model First-party; no third-party egress
Code interpreter Myra sandbox First-party; no third-party egress
RAG / knowledge search / file read-write in-tenant vector store No third-party egress

The per-source cells, their keyword counterparts and where refusals are recorded are described in Guardrails — Sources and trust classes.

Block signal (value-dependent sinks). A block fires on a structured, high-confidence identifier only: a checksum-valid German ID (Steuer-ID, USt-IdNr, SV-Nr, KV-Nr, Personalausweis), an IBAN (mod-97), a credit-card number (Luhn), an email address, a JWT, an API key, a [MYRA-REDACT-…] token echo, or a configured custom_pii keyword — and, on a gateway whose pii_protector sets dk_recognizers (any pii_protector detector of the gateway, also a disabled one; a stored non-boolean value counts as set), a separated Danish CPR number: 010190-1234, 010190 1234, 010190 - 1234 or a replacement CPR with a hyphen (150643-0SJ1), also percent-encoded (010190%2D1234, 010190+1234), base64- or hex-encoded. The egress rule is narrower than masking, because a refusal is not reversible: a bare 10-digit number is refused only as the value of a URL parameter or JSON key whose name is a CPR word (?cpr=0101901234, {"personnummer": "0101901234"}, nested and encoded forms included — details in Danish CPR recognizer); under any other name, in a URL path or in prose (even next to the word CPR) it is not refused, nor is 010190/1234 outside such a value (ordinary URL routing). It catches a CPR written in its usual formatted shape; it is not a defence against a deliberate attempt to send a CPR out. Any 6-digit group whose first six digits form a valid day and month followed by a hyphen, space or + and four digits (or, after a hyphen, a replacement-CPR letter group) is refused on such a gateway — about one in 27 random number pairs of that shape, for example an account number 120390-7890 or a phone number with an extension 089 120590-1000; the model receives the refusal and can retry without the number. Without dk_recognizers a CPR is not a block signal of its own (a 10- or 11-character number can still match a German ID check). Free-text names and places pass — the tool needs the real value to function, and blocking every person/location would disable the tool. When an argument object cannot be fully inspected (unparseable / excessively nested), the call is blocked (fail-closed). A blocked tool call returns a model-facing message so the model can retry without the protected data.

Gateway logs

Masking protects what reaches a model; the gateway's own server logs are kept out of the data path altogether. The error log (read by Myra operations and kept for 14 days) and the access log never contain the content of a request: prompt and message text, web-search queries (raw or masked), tool-call arguments, document and extractor output, file names, model answers, provider, MCP and summariser response bodies, the matched Custom PII keywords and the values a database error would quote. A log line names such a value only by its length (<query:42B>); a provider error body by its length and its machine-readable error class (<body:312B type=invalid_request_error code=context_length_exceeded>); a fetched or configured URL by its scheme and host (https://example.com <path:31B>); an e-mail address by its first character and domain (m***@example.com); the erasure of an account is itself logged without the address. The access log records the request path without its query string or referer (/admin/v1/conversations/search, not …?q=…). It also records the client's IP address as forwarded by the CDN, so a failed request can be traced for support. The per-request debug switch x-aig-trace logs sizes, counts and timings only.

What the logs do not cover: a host name or an e-mail domain is kept on purpose (it is what tells an operator which site or which customer failed), so a personal domain (max-mustermann.de) is still visible there. A provider's full error answer stays with the failed request's own record in the access-controlled request log (and in the request trace when the gateway records bodies). The web server itself appends the request line to an error-log entry written while a request is being served. Every search and lookup the app performs (conversation, prompt, agent and web search; the single-sign-on lookup; the member lookup by e-mail) therefore sends its term or address in the request body, which that line does not contain (see Search and lookup values travel in the request body). A knowledge file the app saves by name sends that name in the request body as well (see Saving a text file by name). What remains: a client that still uses the deprecated GET form of those endpoints (?q=, ?email=) or the deprecated path form of the knowledge save (PUT …/knowledge/<file name>), both accepted until 11 January 2027, and the SCIM user lookup an identity provider sends as ?filter=userName eq "…" (the SCIM protocol prescribes it) can still place that value in the error log when such a request also logs an error. The app itself sends only its origin as the referrer, so the page address (which can carry text, such as a shared prompt link) is not added to those entries.

See also