Guardrails API
The guardrails API exposes the configured detector list, recent block events, aggregated statistics, and the per-provider circuit breaker state for a gateway. All endpoints require an authenticated session with access to the gateway — for most of them any user in the gateway's tenant qualifies; they are not restricted to administrators. On recent guardrail events the per-request meta protection markers are additionally withheld from callers without REQUEST_LOGS_VIEW; the events themselves are returned to any user with gateway access.
Listing configured detectors
GET /admin/v1/gateways/<ID>/detectors
Returns the guardrail detectors configured on the gateway, in the order they appear in the gateway configuration (no pipeline-order sort), followed by the organisation's guardrail baseline. Baseline entries carry baseline: true. They run on every gateway of the organisation and cannot be edited or disabled on the gateway (the tenant can switch a rule off with enabled: false; such an entry is returned with enabled: false). GET /admin/v1/gateways/<ID> and the tenant gateway list include the same baseline as a read-only config.guardrail_baseline array, with keywords and patterns redacted for callers who cannot manage gateways, as for the gateway's own detectors. Each entry has these fields:
| Field | Type | Description |
|---|---|---|
type |
string | Detector type. |
name |
string | Detector name. |
action |
string | Action taken when the detector fires. For a prompt_injection detector: block (the default for an absent, null or unrecognised value — this type is the one whose default runs the other way from the content detectors) or flag; scrub is not supported and is treated as block. A flag prompt-injection detector is also always fail-open — see Prompt Injection. For a presidio detector: scrub masks (anonymizes) the matched PII, block rejects the request, and flag only records the match without masking. An absent or null action defaults to scrub (the detector masks) — both at runtime and in the "PII protected" indicators; set action: "flag" explicitly for observe-only. For a regex or keyword detector, scrub masks every matched span in place with the detector's scrub_placeholder (default [REDACTED]) and records the outcome as scrubbed; their default action is flag (NOT scrub), so masking applies only when action: "scrub" is set explicitly. A flag on a top-level turn also queues a moderation review_item (flagged_prompt / flagged_output) that a security reviewer allows/denies/annotates — the queued row carries only the interaction's trace reference and the detector name(s), never the matched content (see Agents → moderation queue). Note that a broad flag pattern generates one moderation item per matching interaction, so scope it deliberately.Accepted shape, and what an absent or malformed value means. action is not validated at the write boundary for any type except pii_protector / custom_pii, which accept only an omitted, null or "scrub" value because they always tokenise. Every other type resolves it at request time and then dispatches on a literal. A value that is not a string is treated exactly like an absent one: an absent action, a JSON null, a JSON false, a number, a boolean and an object all take the type's own default. An unrecognised string is different — it is never performed, and takes the type's else branch (flag for the content detectors, block for prompt_injection). The one exception is presidio, whose own rule normalises only null / false / absent to scrub — so a presidio detector whose action is a number, boolean or object reports flag, not scrub. (prompt_injection is not an exception to this rule: an absent and a non-string action both mean block there. It differs only on unrecognised strings, which it also treats as block.)Previously a JSON null did not take the default: it survived the fallback (it is truthy in the runtime's semantics), matched no literal, and landed on the else branch — so on a type whose default is block a stored null, 7, true or {} bought less enforcement than storing nothing, silently turning a detector that refuses into one that only logs. That is fixed: no malformed value is weaker than an omitted one. If you have a stored non-string action on a prompt_guard, json_schema, contains_code, gibberish or language detector, it now REFUSES where it previously only flagged — the gateway logs a [detector_action] warning naming the detector so the config can be corrected. GET /admin/v1/gateways/{id}/detectors reports the action the runtime will actually apply, never the raw stored value, so for every detector type the gateway recognises its action is one of block, scrub or flag. A detector whose type the gateway does not recognise is the one exception, because nothing here knows what such a detector would do: its stored action is echoed unchanged when it is a string — so this is also the only case where the field can hold something else, including "" — and when it holds no string at all the endpoint reports flag.The defaults, by type: block for prompt_injection, prompt_guard, json_schema, contains_code, gibberish and language; scrub for presidio; flag for regex, keyword and jailbreak. Only presidio, regex and keyword read action and perform scrub — pii_protector and custom_pii always tokenise and never read the field at all, and on every remaining type a stored scrub is not a mask, it is that type's fallback. |
enabled |
boolean | Whether the detector is switched on. A detector with enabled: false does not run — no masking, no block, no flag — with one exception: enabled: false does not exempt a prompt_injection detector at the tool-result seam, where tool results are still scanned and withheld; use fail_open: true or action: "flag" to relax it. Any value other than a literal boolean false (absent, null, true, or a non-boolean) counts as enabled (fail-safe: the detector runs, so a malformed value never silently disables protection). Disabling a PII-masking detector lets that PII flow to the model UNMASKED — the previous behavior always masked regardless of enabled. In the admin console disabling any detector asks for confirmation first (a PII-masking one with this warning, every other type with a neutral prompt), and every deactivation (toggling enabled: false or removing the detector) is recorded in the audit log under the action guardrail_masker.deactivated (actor, gateway, detector name + type — never the detector's keywords/entities). Disabling a masker unmasks text only: inline base64 media is still blocked with pii_media_unmaskable, and a custom_pii keyword list still guards tool / web-search egress, while any PII-protective detector remains present on the gateway (these gateway-level fail-safes over-protect, they never leak). A detector whose only PII masker is disabled is also no longer selected as a PII-preferred route by Auto. |
target |
string | Stage the detector applies to — request (the model input), response (the model output), or both. An omitted target defaults to request.Accepted shape, and what is rejected. A write that introduces a target which is not one of those three strings is rejected with 400 on POST /tenants/{id}/gateways, PATCH /gateways/{id} and the guardrail-config import — including an explicit JSON null. Refusing a new null keeps a single canonical spelling of the default (omit the field); it is a canonical-spelling rule, not a safety one. Read-time semantics: a JSON null target resolves to request. A null, a false and an omitted target all fall back to request, so a detector carrying any of them runs on the request phase and is reported active: true with target: "request" (the report emits the resolved value, never raw null). This matches how a per-role (role_policies) detector has always read a null target, so one stored shape now resolves identically on both carriers. A non-string target that is not false (a number) or an unrecognised string (a typo such as resposne) is not the default — it matches no phase, the detector never runs, and it is reported active: false with inactive_reason: "wrong_phase". A value already stored on a gateway is grandfathered (carried through unchanged) so an existing configuration never becomes unsaveable; a stored null is normalised to request on the next save. A response/both detector inspects the model's answer, so on a streaming request the gateway first collects the full answer (it cannot un-send tokens already streamed) and then applies the detector before delivering it — a response-stage block/mask therefore adds the model's generation time as buffering latency before the first visible byte. |
active |
boolean | Whether the detector can ever match anything. false means it holds no content to match on, or is pointed at a phase it never runs in — the gateway returns pass for it on every request. Distinct from enabled: enabled: false is a deliberate switch-off, active: false is a detector that looks configured but is not. |
inactive_reason |
string | Present only when active is false. One of no_patterns, no_keywords, no_schema, no_languages, wrong_phase. |
How escapes are read
This is the one description of how the keyword and regex detectors read JSON escapes. It holds for the request, the response and tool results, and for block, flag and scrub alike. The detector pages (Keyword, Regex) link here and add only what is specific to the detector.
- Each JSON level is matched on its decoded string text. A level is a document, a document that is cut off (for example at a size limit), or a text the gateway shortened with its truncation notice, which is read as one text including the notice. A field name is matched on its decoded text too (
{"M\u00fcller":1}holdsMüller). A field name written plainly in a tool result is masked like any other text ({"Müller":1}becomes{"<X>":1}); a match on a field name written with escapes cannot be masked in place, so a tool result is withheld (underscrubandblock), a response is blocked, and on a request a field name of the request itself is kept and recorded as scrub not applied, while one inside a tool call'sargumentsblocks the request. Numbers and the JSON syntax are read as written. A value that is itself JSON (a tool call'sarguments, a tool result written as JSON) is read as its own level, at every depth. - The escapes of a JSON level are never letters.
\n,\t,\",\\and\uXXXXare the character they spell:nobodydoes not match insideline\nobody, and\u00fcis found asü. A typed{"path":"C:\newis read as the start of a JSON document, so its\nis a line break andnewdoes not match there. - Text that is not JSON is read as written. Prose such as
C:\temp\newcontains the wordnew; its backslashes are not an escape, and a typedC:\daten\nHansenin a plain-text response does not match the whole wordHansen. When such text sits inside a string value of a JSON document, or looks like a cut or malformed JSON document, a typed escape sequence in it is also read once more as the character it spells, so thereC:\daten\nHansendoes matchHansen(this includes the text of a chat message, which is a string value of the request). - Limit: a cut inside an encoded document. When a JSON text is cut off inside a value that is itself an encoded JSON document, and the cut part holds only escapes, the detector still acts on it. The gateway errs on the safe side here: such text blocks under
block/flagand is masked underscrub; it may act on more than a strict reading would, never less. - A tool result whose hidden match cannot be masked in place is withheld. When a match runs across several string values of a tool result and the gateway cannot mask it so that the forwarded result reads clean at every level (for example next to another match it masks, or next to a value nested past the depth limit), the tool result is withheld (under
scrubandblockalike) and the conversation continues. Also withheld: a match that only repeated decoding reveals (a document encoded more than once), a result whose string-encoded documents are nested more than 15 levels deep, and a tool result that is only a JSON string whose match is spelled with escapes inside it. A match on a number in a tool result is masked as plain text, so that result is then no longer guaranteed to be valid JSON ({"card":4111111111111111}becomes{"card":<X>}). A block withholds that one result ([tool result withheld: blocked by a gateway guardrail]) and the conversation continues; for program output a block at the 64 KB output cut withholds only that output stream, and the program's files are still delivered. - Overlapping or touching matches merge into one placeholder wherever the text is read per JSON level (request messages and tool-call arguments, a JSON response and the values inside it, tool results written as JSON): the keywords
abandcdoverabcdgive one placeholder. In text read only as written (a plain-text response, a request body that cannot be decoded) matches that touch keep separate placeholders and only overlapping matches merge. Matches that neither overlap nor touch always get their own placeholder. - On the response, the detector's own placeholder is no match, so an answer that already holds it is not refused again. The exception: when a keyword or pattern of the detector (an anchored pattern included) matches the whole placeholder, the placeholder is a match like any other text; the answer blocks or flags, and a scrub withholds the answer (the gateway never masks with a placeholder the detector itself matches). A match only in a field name, only in a number, or inside a document that is encoded as a string more than once blocks the answer instead of masking it.
Detectors that can never match
A guardrail with nothing to match on is stored, listed and counted like any other, but the gateway
returns pass for it on every request. Reading such a detector as protection is the failure mode
this field exists to prevent — a regex with action: "block" and no patterns at all presents as
the strictest setting available while blocking nothing.
inactive_reason |
Detector types | Condition |
|---|---|---|
no_patterns |
regex |
Neither patterns nor custom_patterns yields anything usable. A patterns entry that is not a known pattern or set name — a typo such as credit_card for cc — is silently ignored, so a non-empty patterns array can still leave the detector unable to fire. |
no_keywords |
keyword, custom_pii |
keywords is absent, null, not an array, or holds no non-empty string. An empty-string keyword is skipped at match time, so [""] matches nothing. |
no_schema |
json_schema |
schema is absent (or false). A schema that is present but unusable (JSON null, a scalar, an array, a malformed required / properties / constraint) is not reported inactive — the detector still runs and refuses (or, with action: "flag", flags) every response with invalid_schema_config until the configuration is corrected; POST / PATCH /gateways and the guardrail-config import reject such a schema with 400 so it cannot be stored. |
no_languages |
language |
allowed is absent, false or an empty array. A null or non-array allowed is not reported inactive — the detector errors rather than passing, and a non-empty list of unusable entries blocks every request. |
wrong_phase |
any type | The target matches no phase, so the detector never runs — a typo (resposne) or a non-string that is not false (a number). An omitted target, a JSON null, and false all resolve to request and so are not wrong_phase — the detector runs. Also reported for json_schema and gibberish, which run only on the response phase, when target is left at the request default. |
Only a detector the gateway provably treats as a no-op is reported inactive — the report mirrors
each detector's own early return, including its edge cases, so a detector that errors or that
blocks everything is never described as harmless. Detector types that ship working defaults are
never reported inactive: a jailbreak with an
empty keyword list keeps its built-in phrases; a prompt_guard with no categories enforces
every category; a presidio or pii_protector with no usable entities analyses every entity
type. A malformed detector, or a type the gateway does not recognise, is likewise reported as
active — reporting a working detector as dead would lead an operator to delete protection that
does run.
active is always present; inactive_reason only when active is false. The de_recognizers / dk_recognizers flags and the scrub_placeholder string are configuration inputs (on a pii_protector, resp. a regex / keyword scrub detector) — not returned fields. scrub_placeholder (default [REDACTED]) is the text substituted for each matched span when action: "scrub". It is inserted literally on both a keyword and a regex detector (a % is not interpreted; previously a regex detector used it as a pattern replacement string, so %0 re-inserted the matched text and a literal % had to be written %% — such a placeholder now shows %%; write a single %).
When a scrub cannot be applied. A keyword / regex scrub replaces text over the whole JSON document, so a keyword or pattern that matches a JSON key (content, role, text, model, …), or a placeholder that contains " or \ (which break JSON validity), would rewrite the document's structure rather than a value. The gateway compares the masked document's shape at every depth with the original — the same keys, the same array lengths, and only string values may differ (a number, boolean or null must be byte-identical: they are unquoted in the encoded body, so a digit pattern with a numeric placeholder would otherwise rewrite max_tokens or created, and a keyword true would flip stream) — and refuses to commit a mask that changed it. This whole-document comparison applies where the scrub still works on the encoded body: a request whose body cannot be decoded, and the one whole-text pass a regex scrub makes on the response phase for its anchored patterns (^, $). On the request phase a body that decodes is not masked this way at all: each JSON level is matched on its own and only the parts of a match that lie inside string values are replaced (see below), so a keyword or pattern that equals a field name or matches a number, boolean or null never rewrites the structure. What happens when a scrub cannot be applied differs by phase, deliberately: where the request body is still masked as a whole document, nothing is masked, the request is marked scrub_uncommittable and the detector reports pass — the body stays intact so the PII layer (tier 2) still sees and masks it; on the response phase the detector blocks (block_reason: scrub_uncommittable, no gap marker — the layer did protect) — there is no layer behind a response scrub, and a pass would deliver the matched term to the user. Previously the response phase had no check at all and shipped the corrupted body while recording scrubbed. Because a scrub on a key can never be applied — and on the response phase would block every response — POST / PATCH /gateways and the guardrail-config import reject a keyword scrub detector whose keyword is a JSON envelope field name (content, model, role, type, name, id, messages, choices, …) with 400; a regex pattern is not judged statically. Note in particular the unquoted numeric envelope fields of an OpenAI-shaped response (created, index, usage.*): the built-in phone and npi patterns (and the bundles that include them — pii_basic, gdpr_structured, hipaa_structured) match a ten-digit created timestamp, so a response-phase regex scrub with one of those patterns is blocked on every response (pii_in_number); use such patterns on the request phase, or a pattern anchored to the value's real shape. Scrubbing the string values of the decoded document instead of the encoded body removes the key-, number- and boolean-hit classes at the root; a keyword or regex detector works this way on the request phase and on the response phase (on the response phase a regex scrub's anchored patterns are matched once more against the whole answer as written, and that pass is held to the whole-document comparison above). On the response phase the values of the decoded document are read per JSON level as described under How escapes are read. A value that is encoded several times is checked at every decoding level, not only the last one, so a term that is visible only at an intermediate level is found too. A scrub of such a value re-encodes only that value; a scrub hit that cannot be masked in place — an object key inside arguments, or a value nested deeper than the gateway decodes (64 decoding steps) — blocks the answer (the uncommittable rule). A value nested past that limit is refused rather than passed on unchecked, for block, flag and scrub alike. The same holds for a value inside more than 16 JSON documents nested in one another. A keyword that matches a key or a number is still refused for scrub and blocks as described above. An answer that is not a valid JSON document (plain text, HTML, a body with a raw NUL byte) is matched as the text it is. A request-phase regex or keyword scrub masks the string values of the whole conversation history, including earlier tool results and the arguments of earlier tool calls (which stay valid JSON). It behaves as follows: a match in an object key inside tool-call arguments blocks the request (scrub_uncommittable), because the key cannot be masked without changing the call; a match in a number blocks it with pii_in_number; a match in a field name of the request itself (for example a keyword model) is kept and recorded as "scrub not applied", also when other values were masked; when nothing could be applied the detector reports pass and the request carries the scrub_uncommittable marker; and a match the gateway cannot mask in place (inside a document that is encoded as a string more than once, inside a document nested deeper than the gateway reads, visible only after further decoding of a value, or in a value nested past the decoding limit, which is refused), blocks the request with scrub_uncommittable; the body is left unchanged. A request-phase regex or keyword scrub never rewrites a JSON number: when a match overlaps one (a card number sent as a number, a timestamp or ID, the fraction digits of a float) the request is blocked with the reason pii_in_number instead of being masked, and the scan sees a number's exact digits (see JSON number fields). A pattern or keyword that spans a value and the structure around it (for example password%W+%w+ over a tool call's arguments, where the separator is the closing quote, colon and opening quote) is matched on the text of each JSON level as a whole: the part that lies inside a string value is masked, the JSON syntax and keys around it are left as written, and the arguments stay valid JSON. A match inside a JSON document carried in a string value (such as arguments) is matched at that document's own level; a document encoded as a string more than once blocks as described above. Text that already holds the scrub placeholder is not masked a second time. See German structured-PII recognizers below for de_recognizers.
A request refused by a masking detector (a regex or keyword scrub, a PII masker) is logged with its prompt masked or withheld, never with the refused value in clear; see Request log.
Required role: any user with access to the gateway's tenant.
Configuration shape and malformed input
The detector pipeline is the guardrails array in the gateway configuration. Each
element must be a detector object. The legacy detectors key is accepted as a
fallback, but only when guardrails is absent (the key is missing) or the
boolean false; a present-but-null (or scalar, or object) guardrails value takes
precedence and resolves to zero detectors — it does not fall back to the legacy
detectors key. In other words, an explicit "guardrails": null behaves identically to
an empty array "guardrails": [] (no detectors configured), while a config carrying
only the legacy "detectors" key and no guardrails key uses those legacy detectors.
The gateway never fails a request with a server error over a malformed value: a null
array, a scalar, or an object in the guardrails position all resolve to zero
detectors, and any non-object elements in the array (null, numbers, strings) are
ignored. This is fail-safe, not a bypass: a gateway with no active PII detector still
cannot serve a request under a project whose permission tier mandates PII masking — that
request is blocked before anything leaves the gateway. When updating a gateway with
PATCH /admin/v1/gateways/<ID>, a config of JSON null is treated as "no change"; a
non-object config is rejected with 400.
Classified-document markings (block_category)
A keyword detector may carry an optional block_category field. The only accepted value is
"classified_marking"; it marks the detector as a classified-document-markings rule. Any other
value (including a non-string), the field on a detector of another type, on a detector whose
action is not "block", or on a detector inside a role_policies entry (the preset is gateway-level)
is rejected on write (400). An absent field is an ordinary keyword detector.
The ready-made preset config/guardrail-presets/classified-markings.guardrail-config.json
(German VS-NfD / VS-VERTRAULICH / VS-GEHEIM / STRENG GEHEIM, NATO, EU and COSMIC markings) is applied with
POST /admin/v1/gateways/<ID>/guardrail-config/import. The import replaces the gateway's guardrail
subset, so merge the two detectors into the gateway's existing guardrail export first, then import. Both of its detectors use action: "block",
target: "request" and fail_open: false.
- Matching. A detector with
block_categoryalso matches the typography-normalised text, so a non-breaking or soft hyphen, an invisible character (zero-width, bidi or format control, variation selector — the Unicode default-ignorable code points), an NBSP, a line break, a doubled space or a combining diaeresis inside the marking does not evade it. The prose rule also lists the hyphenatedDienst-gebrauchspelling, so a marking hyphenated across a line break is still caught. Normalisation only decides block or flag and never rewrites the request. - Notice. The block is a
guardrail_blockedblock withcategory: "classified_marking". The notice never shows the keyword or the rule name. An external API client receives fixed prose with no keyword and no detector name. - Attachments. A gateway carrying the preset (the key present, with any value, on a top-level
keyword detector, whether or not the detector is enabled) forces images and other media to be
converted to text first, as on a privacy gateway. Media that cannot be scanned as text is refused with the
block reason
classified_media_unscannable(error classguardrail_classified_media). This media rule also applies on a wholly-local leg (skip_masking), and a gateway that also carries personal-data protection keeps thepii_media_unmaskablerefusal. A disabled preset detector no longer blocks text, but media is still forced to text. - Word documents. Text in a Word header or footer is extracted and scanned, so a marking stamped there is found. A marking inside a text box in the document body is not extracted. A document with more than 64 header/footer parts is refused (fail closed) rather than partly scanned.
The same fail-safe rule applies inside a detector object. The request body a detector
inspects is raw client JSON, so no member of it is trusted: a messages value that is not an
array, an element of messages that is not an object, a content that is a number, a text
block whose text is JSON null, and a system / prompt / input / instructions of any
non-string type are each skipped rather than indexed. Nothing in a request body can make a
detector throw, because a throwing detector resolves through fail_open and — on the default
fail_open: true — would let the request through unscanned. Likewise an entities value that
is not an array of strings means "every supported entity type", never "no entity types".
German structured-PII recognizers (de_recognizers)
The hosted PII analyzer is US-centric and misses German structured identifiers — a
Steuer-ID, for example, is scored as a weak phone-number match and would pass
through to the model unmasked. Setting de_recognizers: true on a pii_protector
detector adds gateway-side recognizers that catch these by format + checksum
and tokenize them the same reversible way as every other PII value (the user sees
the original in the final answer; the model and any logs see a token). They run on
both the request body and tool results (read_file / knowledge / web-search
output), so an ID arriving via a document is masked too.
Each German recognizer validates a checksum, so an ordinary number of the same length is not masked (no over-redaction). (The Danish CPR recognizer below has no checksum and relies on shape and context instead.) Detected types and accepted shapes:
| Entity | Accepts | Rejected |
|---|---|---|
DE_STEUER_ID |
11 digits, ISO 7064 MOD 11,10 check digit (separators tolerated: 86 095 742 719; 12345678901 is rejected — its check digit would be 3) |
any 11-digit number failing the checksum |
DE_UST_IDNR |
DE + 9 digits, MOD 11,10 check |
wrong check digit; missing DE; leading-zero block |
DE_KV_NR |
1 uppercase letter + 9 digits (eGK Versichertennummer), Luhn check | lowercase; wrong length; failed check |
DE_SV_NR |
AA TTMMJJ B NN P Rentenversicherungsnummer, weighted check digit |
missing the birth-name letter; failed check |
DE_PERSONALAUSWEIS |
9 alphanumeric + ICAO-9303 (7-3-1) check digit | digits-only without the check; failed check |
An ID that directly follows a shorter number is masked in full even when that number plus the
ID's first groups happens to pass a check digit too (15 12 345 670 005): both matches are
masked together as one token, labelled with the type of the earlier match. The same holds across
the Danish and German recognizers: a Steuer-ID that continues past a CPR-shaped number in front
of it (010190-1234 567 0005) is masked in full.
Separators. Every German type tolerates separators between its groups: space, ., -, /,
and their typographic forms as they arrive from word processors, PDFs and web pages —
non-breaking, narrow non-breaking, thin, figure and other fixed-width spaces (U+00A0,
U+2000–U+200A, U+202F), hyphens and dashes (U+2010–U+2015, the minus sign U+2212), and the
invisible zero-width space (U+200B), word joiner (U+2060) and soft hyphen (U+00AD). So
86 095 742 719 grouped with non-breaking spaces, or a Danish CPR 010190–1234 with an en dash,
is masked, and the token restores the original characters exactly. Not folded: fullwidth digits or
letters, and characters from other scripts — an ID written that way is not recognized.
In pasted spreadsheets, a line that holds only such spaces does not end a table the way an
empty line does (it is usually an empty paragraph pasted from a web page or a document); a
typographic dash behaves like - (a – placeholder cell is a non-empty cell). Column headers
are matched as written: a header spelled with a non-breaking space or hyphen (Steuer ID) is not
recognized as a label. The Danish CPR keeps its own grouping rule (below); a typographic dash or space
between its groups counts as - or a space.
Scope. This closes the leak of structured German identifiers. German
names and addresses are free-text NER, handled separately by the detector's
language calibration — see below.
Survives a PII-analyzer outage (degrades closed). The German structured-ID
recognizers are pure gateway-side format + checksum checks with no dependency on
the hosted PII analyzer. If the analyzer is unreachable when a request is scanned,
these recognizers still run and still mask the structured identifiers they
recognize — so a Steuer-ID / USt-IdNr / KV-Nr / SV-Nr / Personalausweis is masked
even during an analyzer outage on a fail_open gateway (where the free-text NER
would otherwise degrade). The analyzer-outage signal is preserved independently, so
a non-fail_open gateway still blocks on the NER outage (fail-closed) as before.
This strengthens the "nicht abschaltbare Maskierung deutscher Personendaten"
guarantee for the structured-ID family.
Accepted input, and what is rejected. The scanned text is caller-controlled — a message, an uploaded document, a fetched page, or a tool result — so it is treated as untrusted. Two classes of text are exempt from the scan, and no others:
- the regions this request has already masked, skipped so a digit run inside a redaction token is not masked twice (which would make the original unrecoverable) — described below;
- cells the table classifier reads as a numeric metric column rather than an ID column — never a cell under a header row that names an ID, and never a cell with an ID label to its left in the same row — a precision trade-off documented under German structured IDs in spreadsheets and tables. The tool, web-search and MCP egress seams re-scan suppression-free, so that exemption does not extend to them.
That exemption is keyed on the request's own mask record, never on the appearance of the text. Concretely:
| Input | Scanned |
|---|---|
A redaction token produced by this request ([MYRA-REDACT-…], [MYRA-CUSTOM:…]) |
No — already masked |
The same shape typed by the caller, e.g. [MYRA- … ] or [MYRA-REDACT-X …] |
Yes |
| A token from another request, or a truncated / re-cased one | Yes — it cannot be restored, so there is nothing to protect |
| Malformed, empty, or absent mask record | Yes — the whole text is scanned (absent and malformed share the protective path) |
A shape-based exemption would be caller-controlled and would therefore let anyone put a checksum-valid German ID beyond the recognizers' reach by typing a prefix.
The same mask record governs the NER spans the pii_protector detector emits: an
analyzer span — untrusted third-party output — is clamped in-bounds and then clipped to the
prose around the request's own tokens before it is masked, so a span over a token this request
produced masks nothing, a straddling span masks the text on either side, and a caller-typed
token shape is masked like any other text. A span clipped away entirely is not reported as a
masked entity.
The presidio detector's anonymizer request is canonical: per span exactly
{ entity_type, start, end, score } — a string label (entity_type, else the type alias,
else PII), integer offsets clamped inside the field (a fractional offset widened, an
out-of-range one clamped — a superset is masked, never less; only a span that cannot be placed
at all is dropped), a finite score in [0, 1] — duplicates collapsed to one span with the higher
score, whitespace-only spans dropped. Observed sidecar behaviour (measured and replicated against
the anonymizer sidecar; this is the sidecar's own behaviour, not a gateway rule): a null / empty /
alias-only label is refused 422, an object label 500, a fractional offset 422, an infinite
score cannot be encoded; a whitespace-only span is accepted but inserts a placeholder between
two words; an exact duplicate is accepted with a rare sporadic 502. An anonymizer failure on a
field with detected personal data is a fail-closed refusal, so the untrusted analyzer response is
normalised before it reaches that boundary. The same label rule (presidio_chunk.span_label)
names the span in every verdict and token, so a malformed label can no longer throw the detector
into an error verdict that a fail_open detector would forward.
Field-name nouns tagged as structured PII
The analyzer's NER model sometimes labels a field-name noun with a structured type at high
confidence — "email" or "gmail" as EMAIL_ADDRESS, "passport number" as PASSPORT, "phone" as
PHONE_NUMBER. Before any span is masked (by presidio and pii_protector alike, for every chunk
of a large text), the gateway drops a span of a structured type whose whole text is a word on a
closed list of such nouns.
Types checked: EMAIL_ADDRESS, PHONE_NUMBER, CREDIT_CARD, IBAN_CODE, US_SSN, US_ITIN,
US_BANK_NUMBER, PASSPORT, US_PASSPORT, US_DRIVER_LICENSE, MEDICAL_LICENSE, IP_ADDRESS,
URL, CRYPTO. Every other type (names, places, organisations, dates, the German and Danish ID
recognizers) is unaffected; generic role nouns tagged as PERSON are handled by the
PERSON stop-list.
The list (English and German, independent of the detector language) holds compound and
technical field nouns and provider names, for example: email, E-Mail, E-Mail-Adresse,
email address, Postfach, inbox, gmail, Gmail-Konto, googlemail, gmx, web.de,
yahoo mail, hotmail, icloud, posteo, t-online, protonmail; phone, phone number,
mobile number, Telefon, Telefonnummer, Handynummer, Rufnummer, Festnetz, Faxnummer,
hotline; passport, passport number, Reisepass, Passnummer, Ausweis, Personalausweis,
ID card; credit card, card number, Kreditkarte, Mastercard, American Express,
girocard, IBAN number, bank account, account number, Kontonummer, Bankverbindung;
SSN, social security number, tax ID, Steuer-ID, Steuernummer,
Sozialversicherungsnummer, driver's license, driving licence, license number,
Führerschein; IP address, IP-Adresse, IPv4, IPv6, URL, hyperlink, website,
Webseite, homepage; wallet address, bitcoin, BTC, ethereum.
Matching ignores case, -, _, apostrophes, repeated ASCII whitespace and a trailing : or .
(E-Mail = email, Telefonnummer: = telefonnummer). Spaces are not removed, so a phrase
matches only a phrase on the list (credit card) and a spaced name never joins into one
(Mai L. is not mail). A dot or @ inside the text is kept, so a real address or domain never
matches (bit@co.in is not bitcoin, web.site is not website), and a span with @ is never
treated as a noun. A span with anything more (the email) stays masked. Single words that are also
a surname or given name somewhere (Link, Swift, Card, Handy, Pass, Cell, Ip, Visa,
Iban, Itin, Fax, Wallet, Bic, Domain, Mail, Tel, Konto, Karte) and bare generic
words (number, account, license, mobile) are deliberately not on the list, so they stay
masked when the model tags them.
Fails toward masking. Only the exact listed words can go unmasked. Anything else the model
tags stays masked, including a real value given the wrong type (a login max.mustermann tagged as
an e-mail address, a name tagged PASSPORT), an obfuscated address (john%40example.com,
max at gmail, jean arobase exemple.fr), a number written in words, and a provider domain with
more to it (gmail.com, @gmail.com). A span longer than 64 characters, a span whose offsets
cannot be placed in the text, and a malformed answer that is not a list pass through unchanged
(the rules above then apply).
The PERSON stop-list judges a PERSON span only when
its offsets are whole numbers inside the text the analyzer scanned (0 ≤ start < end ≤ its length in
code points — the field, or for a tool-result window the window together with its surrounding
context). A span with any other offset — negative, past the end, fractional, NaN, infinite,
null or a string — is never dropped by the stop-list, and the action treats it exactly as before:
block refuses and flag records it; scrub masks it as the canonical anonymizer request above
places it (a negative or past-the-end offset clamped into the field, a fractional one widened, an
infinite one taken as the field's start or end), and only a span it cannot place at all (NaN,
null, a string) is left out. In a tool-result window an infinite offset cannot be placed either
and counts as an unplaceable entity.
Custom regex patterns (custom_patterns)
A regex detector's custom_patterns are Lua patterns, checked when a gateway config is written — POST /tenants/{id}/gateways, PATCH /gateways/{id} and the guardrail-config import and dry-run. Accepted: an array whose non-empty string elements are Lua patterns the engine can run (absent, null, [], empty strings and non-string elements are accepted unchanged — they match nothing and the detector list reports no_patterns). Rejected with 400 (nothing stored; the message names the detector, the pattern's position and the reason) — only a pattern the engine cannot run: a Lua syntax error (unclosed [ or (, a stray ), a trailing %, %b/%f misuse, a back-reference to a capture that is not complete), more than 32 captures, a pattern too deep for the matcher (each quantified item counts 1, each capture 2, each () position capture 1 — the engine raises "pattern too complex" at a total of 200), or a NUL byte in a pattern with special characters (the matcher ignores everything after it; match one with %z). A pattern with none of ^ $ * + ? . ( [ % - is a plain substring search and is always accepted. There is no length limit beyond the request body cap. The export leaves out stored patterns that cannot run, so an exported file imports onto any gateway. A pattern that runs is accepted even if it cannot match what was meant — regular-expression syntax such as \d{4}, {n} or | is valid Lua that matches literal text, and a - after an item is a lazy quantifier. To check what a pattern matches, send it as a one-detector candidate to POST /gateways/{id}/guardrail-config/dry-run with your sample text in samples (the Guardrail Builder's Test against sample text does exactly this, with action: "flag": after: "flag" means it matched and "pass" that it did not; a new pattern that cannot run is refused with 400, and a stored one — sent under the same detector name and carrier as on the gateway, as the Builder does, so grandfathered — is listed in unrunnable_patterns). A pattern string already stored on the same detector (same carrier — the legacy detectors list counts as guardrails — same type and name) is carried through unchanged; an added or changed pattern, a pattern copied to another detector or carrier, and the patterns of a renamed detector are checked.
Danish CPR recognizer (dk_recognizers)
The hosted PII analyzer has no Danish recognizer: a CPR number (personnummer) scores at most 0.4
as a phone number and egresses unmasked. Setting dk_recognizers: true on a pii_protector
detector adds a gateway-side CPR recognizer. A match is tokenized the same reversible way as every
other PII value (DK_CPR, placeholder [CPR]): the model and the logs see a token, the user sees
the original in the answer. Like the German recognizers it runs on the request body and on tool
results, and it still masks when the analyzer is unreachable (degrades closed; the analyzer error
is preserved, so a fail_open: false gateway still blocks).
No checksum. CPR numbers issued since 2007-10-01 no longer satisfy the old modulus-11 check, so
a checksum gate would reject real numbers. The recognizer checks that the first six digits are a
real day and month (DDMMYY; 29 February is accepted for every year) and relies on the number's
shape and context — the rule used by Microsoft Purview's recommended confidence level.
| Written as | Masked |
|---|---|
010190-1234, 010190 1234, 010190/1234, 010190 - 1234 |
always |
Replacement CPR with letters, 150643-0SJ1, 150643-ABCD (only with -) |
always |
Bare 0101901234 |
only when the request mentions CPR — a word starting with cpr or personnum, or the word personnr (CPR:, CPR-nr., cprnr, personnummer, Personnummeret, personnumre), before or after the number, anywhere in the request (see CPR context below) |
| Cells of a table column whose header contains such a word | the whole column, once one cell is a recognised CPR — or when every value is a 9- or 10-digit number (a spreadsheet that stripped the leading zero: 101901234) |
CPR context. The word does not have to sit in the same text as the number. It counts when it appears in:
- any message of the request — the user's own, the assistant's question ("Hvad er borgerens CPR-nummer?" followed by the user's "0101901234"), or a system message sent by the client;
- the rest of a fetched web or text page that is shown in parts (also the parts not shown yet);
- the document a knowledge passage or a document read comes from (also the parts not shown);
- every message of a conversation that is summarized, including the text cut from a long message;
- an earlier tool result or document part of the same request that was already scanned.
Once a request mentions CPR, every later scan in it reads a date-valid bare 10-digit number as a
CPR (this also applies to a web-search query the gateway scrubs, where the number is then removed
from the search). The English word "CPR" (resuscitation) counts as well.
The context does not reach the conversation's own messages from what the gateway adds to the
system prompt — it is composed after the messages are scanned. Memories and the user's background
count for tool results and pages scanned later in the same request; organisation and project
instructions count only when the detector scans system text (skip_system_messages: false, or a PII
mandate). The context does not reach either: pages of a document outside a requested page range (never extracted);
text cut from a document or tool result beyond its size limit; a tool result that was masked before
another tool result of the same step named CPR; a delegated agent's own request; and, on a gateway
whose primary model is local (the request phase does not run there), the conversation for an
external agentic-fetch or summary model. The PII scrub preview and the guardrail dry-run look at a
single text: they can show a bare CPR as unmasked that the live request masks.
Not masked (accepted gaps): an unlabelled bare 10-digit CPR in a request that never mentions CPR; a 9-digit Excel-stripped CPR outside a recognised CPR-headed column — a block is only read as a table when every line has the same number of cells, so a spreadsheet row with an empty trailing cell, a title line directly above the header, or a column holding any non-number value (ukendt, N/A) falls back to the prose rules;
dotted 01.01.90-1234, 01 01 90 1234, 010190.1234, a tab or a line break between the two groups, lowercase
replacement numbers, and a CPR glued to uppercase letters (CPR0101901234). (A typographic dash or
space between the groups — en dash, minus sign, non-breaking hyphen or space — counts like - or a
space, see Separators above.)
Egress refusal. On a gateway with dk_recognizers on, a separated CPR also makes the gateway
refuse a URL fetch (fetch_url, agentic fetch, a workflow Fetch node) or an MCP tool call
(chat or a workflow Connector node) that carries it — the same refuse-not-scrub policy as for a
German ID, because a URL or tool argument cannot be tokenized and still work. Refused:
010190-1234, 010190 1234, 010190 - 1234, a replacement CPR with a hyphen (150643-0SJ1) —
raw, percent-encoded (%2D, %20, +, double-encoded), base64 or hex.
A bare 0101901234 is refused only where its name says CPR: as the value of a URL query or
form parameter, or of a JSON key, whose name is a CPR word — a word starting with cpr or
personnum, or exactly personnr, in any case, also inside a longer name after a character that is neither a letter nor a digit
(patient_cpr, CPR-nr, cpr[]) or as a camelCase part (patientCpr, personNummer). Refused:
?cpr=0101901234, &personnummer=0101901234, {"cpr": "0101901234"}, a nested
{"patient": {"cpr": "0101901234"}} in MCP arguments, a list or object under such a key
({"cpr": ["0101901234"]} — everything under the key counts), a JSON number that lost its leading
zero ({"cpr": 101901234} — a quoted "101901234" is a string and is not padded), JSON written inside a URL or an argument string ('{"cpr": …}',
also escaped or Python-style quotes), and the same with the name or the value percent-, base64- or
hex-encoded or rot13'd. Under such a name the value is read the way masking reads a text that
mentions CPR, so 010190/1234 counts there too. Not refused: a bare 0101901234 under any
other name (?id=0101901234, {"order": "0101901234"}), in a URL path, or in running text
without a = or a quoted name — even next to the word CPR (CPR: 0101901234); 010190/1234
outside a CPR-named value; and the forms masking also misses (above, plus 010190--1234, 010190-1234DK, an underscore, tab or line break
as separator, and a CPR split across two arguments). A CPR-named key is recognised only in the
name=value and JSON (or Python-style) "name": value forms. Not recognised: a name and value
stored apart ({"name": "cpr", "value": "0101901234"}, {"field": "cpr", …}), unquoted forms
(YAML cpr: 0101901234, a header line X-CPR: …, ?q=cpr:0101901234, GraphQL person(cpr: …),
OData cpr eq '…'), a name separated from = by spaces (SQL or config style cpr = '0101901234'), a \u-escaped or doubly escaped key, a quoted name longer than about 60
characters, a short name encoded on its own (under 12 characters of base64 or hex) or an encoded name written
directly after a /, and a value glued to capital letters (DK0101901234, 0101901234X). Any date-valid 10-digit value under a CPR-named
name is refused — also one that is not a CPR (a cpr_lookup_ts=1012345678); a name that only
reads as a CPR word once decoded (rot13 pce) counts, and so does a quoted phrase directly before a
colon ("see the CPR register": 0101901234). This catches a CPR written in its usual shape, not a deliberate
attempt to smuggle one out. The rule is the shape alone (a + counts as a space anywhere in the inspected text, as in a URL
query), so any DDMMYY-NNNN-shaped value with a valid day and month is refused on such a gateway (an account number 120390-7890, a phone with
extension 089 120590-1000); the model gets the refusal and can retry without it. The flag is read
from every pii_protector detector of the gateway, also a disabled one; a pii_protector defined
only inside a role policy does not enable the refusal. An argument value, key or bare string argument longer than 16 KiB (16,384 bytes) cannot be inspected completely, so
the call is refused (see PII protection on outbound tool-call arguments).
Masked although not a CPR (accepted over-masking — reversible): date-keyed identifiers written
like a separated CPR (251013-0042, 251013-TEST); a separated DDMMYY hhmm date and time; and,
in a request that mentions CPR, any other bare 10-digit number with a valid day and month (an epoch
timestamp, a phone number). Date-times (15.01.2024 10:30), ISO timestamps, phone numbers in their
usual groupings and decimals are not matched by the shape rule.
With both flags on, the Danish recognizer claims its matches first: a German match that ends
inside a CPR, or that wraps one, is dropped, so a German ID-card window that starts one token
earlier (Sag 2023 010190-1234) cannot swallow or relabel the CPR. A German ID that continues past a CPR-shaped
number is kept, so its tail is masked too.
Tables. A CPR in a table is never dropped by the numeric-column rule that keeps coincidental
checksum hits out of metric columns: that rule exists for single-check-digit coincidences, and a
separated or context-gated CPR is not one. With both flags on, a row with a CPR word to the left of a value
(CPR-nr.;…) also keeps a German checksum hit in that value masked.
Configuration. dk_recognizers accepts true or false, or may be omitted (off). POST
/tenants/{id}/gateways, PATCH /gateways/{id} and the guardrail-config import reject a write that
introduces null, a string, a number, an object or an array with 400. A non-boolean value already
stored is carried through unchanged and is read as on — it masks (and refuses) more, never
less. Only the pii_protector type reads the field.
Labelled Danish identifiers (CVR, SE, bank account, passport, driving licence)
With dk_recognizers: true the same detector also masks five Danish identifiers — but only when a
label stands right before the value. None of them has a checksum that tells it apart from an
ordinary number (an 8-digit CVR check passes about one Danish phone number in eleven), so this
recognizer never masks an unlabelled number (a number written like a Danish phone number is masked by
the phone recognizer below). Each value is tokenized the same reversible
way; the label itself stays readable.
| Entity (placeholder) | Labels (any case; Danish and English) | Value |
|---|---|---|
DK_CVR ([CVR]) |
CVR, CVR-nr., CVR-nummer(et), moms-nr., momsnummer, momsreg.nr., momsregistreringsnummer, VAT no., VAT number; a DK prefix (DK12345678, DK 12345678, DK-12345678, uppercase) |
8 digits, or 12 34 56 78 / 1234 5678 |
DK_SE_NR ([SE-nr.]) |
SE-nr., SE.nr, SE-nummer (any case); SE nr. / SE nummer only in capitals on one line (Se nr. is "see no.") |
as CVR |
DK_BANK_ACCOUNT ([bank account]) |
konto, kto, kontonr., kontonummer, NemKonto, bankkonto, lønkonto, account, acct, account number, account no., bank account |
one group of 6–12 digits, or a 4-digit registration number and 6–10 digits (1234-1234567890, 1234 1234567890); an account split by spaces is masked whole up to 12 digits (123456 7890, 1234 5678 90) |
DK_PASSPORT ([passport number]) |
pas (a whole word — never pasta, passer), pasnr., pasnummer, passnummer, passport, passport no., passport number |
9 digits, or 123 456 789 |
DK_DRIVING_LICENCE ([driver's license]) |
kørekort (also koerekort / korekort), kørekort-nr., kørekortnummer, driving licence, driver's license |
8 digits |
Adjacent means the value follows the label after nothing but spaces, :, ., -, #, =,
quotes, a short parenthesis, one cell delimiter when the label starts its line (| CVR-nr. | 12345678 |,
CVR;12345678, Kontonr.<TAB>1234567890), and the words nr, no, nummer, nummeret, number,
er, is ("My passport number is 123456789", "CVR-nummeret er 12345678"). Key forms in JSON, CSV or
tool output count too: account_number, accountNumber, bank_account, vatNumber, cvrNummer,
drivers_license, passport_number. Typographic spaces and dashes inside the number are read like
plain ones.
Where a value ends. The value is the digit run after the label (groups joined by spaces, or by one
dash in the registration + account form); the longest part of that run that has the identifier's
shape is masked, and it must be followed by whitespace, any punctuation (quotes, …, brackets,
arrows) or the end of the text — never by a letter or digit, a decimal or amount tail (,50, .500,
,-) or a currency (kr, DKK, EUR, €). So konto 1234 1234567890 2.500 kr. masks the account
and leaves the amount, CVR 12345678 2100 København masks the CVR and leaves the postcode, and
CVR 12 34 56 78 90 masks 12 34 56 78.
Never masked: an unlabelled number; a registration number on its own (Reg.nr. 1234 — a bank
branch code; in Reg.nr. 1234 kontonr. 1234567890 only the account is masked); an amount or a date
after a label (konto 125000 kr, konto 1.234.567,50, 125000,-, Kørekort: 12.03.2030); a
number glued to letters (CVR 12345678x);
an IBAN (DK50 0040 0440 1162 43 — that is the analyzer's IBAN_CODE).
With German IDs enabled too, the label decides the entity: a German checksum hit that starts inside
a Danish label and overlaps its value (CVR-NR. 12345678) is not reported as a German ID; the value
is masked once, as [CVR]; likewise a CPR-shaped number right after an account label
(Kontonr.: 0101901234) is masked as [bank account] (the CPR egress refusal is unaffected). With
both flags on, Danish account labels also apply to German text
(Kontonummer 1234567890 is masked as a bank account); a German-only gateway leaves it alone.
Known gaps: a table column under a header label (| CVR-nr. | over a column of numbers) and a
label in the middle of a row (| Firma | Hansen ApS | CVR-nr. | 12345678 |) are not read — a key/value
line works, a header column does not; a word between label and value other than those above
(konto i Danske Bank: 1234567890); a value in backticks right after the label; an IBAN while the
analyzer is unreachable (only the analyzer recognises it). Name the identifier right before the number,
or add it to a custom_pii keyword list.
Danish phone numbers (PHONE_NUMBER)
The analyzer's phone recognizer has no Danish region, and its name model does not tag a bare
24 66 81 90 in a table cell or a list. With dk_recognizers: true the gateway masks Danish phone
numbers itself, as the analyzer's own type PHONE_NUMBER (placeholder [phone]). Like the other
Danish recognizers it runs on the request body and on tool results, also when the analyzer is
unreachable. Only the number is masked, never the label, so the sentence stays readable
(Tlf.: 23456789 → Tlf.: [phone]).
Denmark has a closed 8-digit numbering plan: no area codes, no trunk prefix, and a subscriber number starts with 2–9 (numbers starting with 1 are short codes and service ranges; 0 is the international prefix). An unlabelled 8-digit number is indistinguishable from a CVR number, an amount or a case number, so a number is masked only when its shape or a label is the evidence:
| Evidence | Masked | Example |
|---|---|---|
| Grouped in pairs | four 2-digit groups joined by one space or non-breaking space, standing alone | Lasse Rask;6000 Kolding;24 66 81 90, 1. Marianne Juhl – 23 81 46 70 |
| Danish country code | +45, (+45) or 0045 (then at most one space, non-breaking space or -) before 8 digits written 23456789, 2345 6789 or 23 45 67 89 — groups joined by one space, non-breaking space, - or ., the same joiner throughout |
+4527830614, +45 2147 8830, 0045 23 45 67 89, +45-23-45-67-89 |
| A phone label | the same three groupings after a label — groups joined by one space, non-breaking space, - or ., the same joiner throughout — also with the country code written without + |
tlf. 40182263, Telefon: 2345 6789, Mobil 23.45.67.89, Tlf. 45 23456789 |
- Phone labels (any case):
tlf,telefon,mobil,mobiltelefon,mob,tel,phone,mobile,fax,telefax,sms, the compoundsmobiltlf,privattlf,arbejdstlf,hjemmetlf,kontakttlf,direktetlf,privattelefon,arbejdstelefon,hjemmetelefon,kontakttelefon,fastnettelefon,direktetelefon, the definite formstelefonen,mobilen, each with a number word glued or after it (tlf.nr.,telefonnummer,mobilnr.), and the phrasesring,ring på,ringe på,ringer på,træffes på,kontaktes på,ring til,ringe til,ringer til,sms til. The gap between label and value follows the rule of the labelled identifiers (decoration, one cell delimiter, number words), but the only words it may cross areer,var,lyderand the qualifiersprivat,priv,private,arbejde,arb,work,hjem,hjemme,home,direkte,dir,fastnet,kontor,dag,dagtid(Telefon (privat): 24668190,Tlf. arbejde 2466 8190). After a label, a list of numbers joined by,,/,;,-, an en dash,ogoreller— each number optionally followed by one such qualifier in parentheses, or preceded by one (with an optional.and:) — is masked number by number, up to nine numbers after one label (tlf. 23456789 eller 87654321,Telefon: 24668190,33123456,Tlf.: 24668190 (privat), 33123456 (priv.),Tlf. privat: 86123456, arbejde: 33123456). The cells of a column headed by a phone label (Telefon,Mobilnr.,Telefon (privat)) are read the same way, and a cell may open with a qualifier (privat 24668190); any other word ends the cell. - Country code without
+: after a label, a leading45is read as the country code when the rest is a valid number (Tlf: 45 23 45 67 89masks the whole value);Tlf: 45 67 89 12is the number45 67 89 12. Without a label,45 23 45 67 89is five pairs and is not masked. - A value ends at 8 digits: written
23456789or2345 6789, a comma, point or slash followed by one or two digits makes it an amount or a ratio (Telefon: 23456789,50,Telefon: 23456789.5,tlf. 24668190/50are not masked;Telefon: 23.456.789,00 kris not a phone grouping at all); a longer digit run after a comma, point or slash is the next number of a list, so both numbers of24668190,33123456,24668190.33123456and24668190/33123456are masked. A number written in pairs is never read as an amount, soLasse,24 66 81 90,6000 Koldingis masked. - Standing alone means: no digit, letter or
+directly before the first pair; no further 2-digit group joined to it by a space or non-breaking space on either side (27 06 90 21 55is a CPR number written in pairs,+46 23 45 67 89a Swedish number,23 45 67 89 12a longer number); no digit group at all joined by-or.(1.24 66 81 90); no digit or letter directly after it. A longer digit group across a single space is another column (Lasse Hansen 24 66 81 90 8000 Aarhus,Kunde 1042 24 66 81 90are masked). A comma or a slash does not join, so a CSV row (Lasse,24 66 81 90,6000 Kolding) is masked. - Not entity-gated. Like the CPR recognizer and the labelled identifiers, the phone recognizer is
an offline gateway-side recognizer: it masks whenever
dk_recognizersis on, regardless of the detector'sentitiesselection, andallow_list/entity_score_thresholds(which the analyzer applies) do not reach it. So Danish phone numbers mask more aggressively than the analyzer's own thresholdedPHONE_NUMBER— additive, not a change to anything already masked. - A number may also be another identifier: where
CVR 37 48 21 90carries a CVR label, the value is both a CVR and a phone shape; the token is labelledDK_CVR(the labelled identifier wins).
Not masked (accepted gaps): an unlabelled 23456789 or 2345 6789 in prose (Sagsnummer
23456789 — the name model still tags most phone numbers in sentences); pairs joined by dots or
dashes without a label (23.45.67.89 — an IP address has the same shape); other groupings
(234 567 89); a number after a phrase not in the list or separated from it by other words
(ringe til Karina på 87135022); a single delimited data line that is not a table (Navn;Telefon
then one contact row — the same structural limit the labelled-identifier column recovery has);
and foreign numbers not written in pairs (+49 151 23456789), also after a phone label — the
analyzer's phone recognizer handles those. A foreign number that is written in four pairs after a
country code (0046 24 66 81 90) is masked by the pair rule.
Masked although not a phone number (accepted over-masking — reversible): any four standalone
2-digit numbers starting with 2–9 (uge 41 42 43 44, a statistics row Region Hovedstaden 32 45 28
61), an unlabelled CVR number written in pairs, and a number of the right length after a phone label
used in another sense. After a label, a longer digit run is masked up to its first 8 digits
(Tlf. 23 45 67 89 01 leaves 01).
When the masker is down, under a PII mandate
A detector that cannot reach its sidecar produces no verdict. By default that degrades and
proceeds (fail_open), which is a deliberate availability choice: a Presidio blip should not take
a gateway down.
Under an active PII mandate it does not. On a pii_mandatory project — or a tenant with
masking enforced — the detector that satisfies that mandate refuses the request instead of
letting it through unprotected, and this is the one place the per-detector fail_open: true flag
does not win. A mandate is a choice of compliance over availability; serving the request
unmasked because a sidecar returned 502 would invert that choice silently, while the gateway went
on being reported as compliant.
Scope, precisely:
| situation | outcome |
|---|---|
| mandate active, masker outage | refused — guardrail_unavailable, marker pii_mandate_masker_unavailable, nothing egresses |
mandate active, fail_open: true set explicitly |
refused — the mandate outranks the flag |
| no mandate, masker outage | proceeds (fail_open honoured, guardrail_degraded recorded) — unchanged |
| mandate active, a NON-mandate-satisfying detector fails | that detector's own fail_open applies — unchanged |
| wholly-local model leg | unchanged: nothing leaves the estate, so there is nothing to refuse — and a tool result bound for that leg is likewise not a mandate case (a tool result on that leg; never persisted content — see the last row) |
| mandate active, the web-search query scan fails | withheld — the search is skipped (the reply says web search is unavailable), whatever the detector's fail_open says; marker pii_mandate_masker_unavailable. The query's bytes leave for the search provider, so the mandate binds here even on a local-only gateway whose model leg is exempt. |
mandate active, a tool-result scan fails (a pii_protector or a presidio scrub detector) |
withheld — the result is replaced by the [tool result withheld: PII scan unavailable] placeholder and the turn continues; marker pii_mandate_masker_unavailable. Not on a wholly-local leg (see above). A withhold is not a gap: none of guardrail_degraded / guardrail_error / pii_scan_degraded is written for it, so the row reads guardrail_gap: false. |
| no mandate, a tool-seam scan fails on a fail-open detector | forwarded with at most the offline structured-ID masking — German IDs, Danish identifiers and Danish phone numbers, where enabled (unchanged) — and, recorded: guardrail_error (name + class), guardrail_degraded, pii_scan_degraded and guardrail_verdict = error, exactly as a request-phase fail-open is — where the forwarded bytes actually leave the estate: not on a wholly-local model leg, not for a detector the agentic-fetch inner leg's own request phase runs again over the document, and not when a later detector (or a later query of the same search turn) withholds the content after all (see Protection markers). Before, such a row read guardrail_gap: false. |
| mandate active, persisted content — a workflow form's uploaded file or an inbound email body on its way into the run state | the persistence fence is a strict leg: the mandate binds whatever the detector's fail_open says and never as a wholly-local case (a local-only gateway's model-leg exemption does not reach persisted content). A masker outage withholds the content behind [tool result withheld: PII scan unavailable]; a mandate with no pii_protector on the gateway withholds it behind [content withheld: personal-data masking is mandatory …] instead of persisting it raw. The fence's throwaway context never reaches a request row, so the durable records are the [tool_result_ner_withheld] … gateway= error line and the model-error triage row (phase = persistence, classifier persisted_content_pii_withheld — its own row, distinct from the chat tool-result one). Ladder: how a run consumes an uploaded file. |
| no mandate, persisted content on a PII-active gateway | masked with the gateway's own maskers (pii_protector, custom_pii, presidio scrub, regex / keyword scrub) — the same coverage a chat turn gets. On the persistence leg an analyzer or masker error or timeout withholds, never forwards, whatever the detector's fail_open says and although a presidio scrub detector is open by default on the chat tool seam (the model leg and the chat tool seam are unchanged). Withhold causes: config_unavailable, mandate_no_masker, masker_unavailable, masker_error, budget_exhausted; a withheld email or form run stops before its first step as failed / content_withheld (see Run fields). Same triage row as above. |
The refusal is retryable and says so, and it names the privacy filter rather than claiming the
gateway is "configured to fail closed" — on a fail_open: true gateway that would be untrue and
would point the operator at a setting that is already the other way.
Names and addresses: the 0.6 floor for every language but English
The PII analyzer's NER model detects PERSON and LOCATION entities, but its
confidence bar for those two high-false-positive types is 0.9 on English text —
tuned for English, where it is well separated from real names. German, Danish and other
non-English names and addresses routinely score 0.6–0.9 (e.g. a plain "Klaus Müller"
≈ 0.79, a city ≈ 0.71, a standalone Danish town ≈ 0.65), so at 0.9 roughly a quarter of
real German names and most addresses would pass through to the model unmasked. Every
detector therefore uses a 0.6 floor for these two types unless its language is set
explicitly to English (since this release; before it, any explicit non-German language
switched the floor off).
A request under a PII mandate gets this floor regardless of language — a pii_mandatory
project, or a tenant with masking enforced. A mandate is the statement that masking is not
optional, so it is applied rather than merely certified: a detector configured language: "en"
on such a tenant still analyses and masks PERSON and LOCATION. Which legs: the model leg,
unless the gateway is local-only (every configured provider first-party — that leg is exempt — for a chat turn; an agent-shaped run on such a gateway is NOT exempt, its output leaves
the estate), and the model-generated web-search query always — its bytes leave for the search
provider, so the local-only exemption does not reach it. Nothing is refused by this —
on a compliance path the fail-safe direction is to mask more, never to serve less. The cost is
false positives, since both types drop to the 0.6 floor; a model leg whose floor
came from the mandate records the pii_floor_forced_by_mandate marker, and a web-search query
whose floor did records pii_egress_floor_forced_by_mandate, so the extra masking can be
explained without reading source. Two seams get no NER floor at all and are governed by a
separate refuse-on-structured-PII gate that deliberately lets free-text names through: URLs
handed to fetch_url and MCP tool arguments.
Outside a mandate, the PERSON / LOCATION floor is fail-safe by default. Whether it
applies is decided by the detector's language field — a request never fails over a
malformed value, and only one kind of value switches the floor off:
language value |
0.6 floor |
|---|---|
absent, "", "auto", or a non-string (number/bool/object) |
ON (fail-safe — a PII gateway that omits language sends "auto"; the analyzer does not use the field and scores German and other non-English names in the 0.6–0.9 band whatever it says, so the floor must apply) |
"de", "da", "fr", "nl", "es", any other locale, and also "deu", "eng", "english" |
ON |
a value that only looks English — "en-", "en_", "en- gb", "en-gb.utf-8", "en" with a non-breaking space or a control character inside |
ON (malformed is never treated as an explicit choice) |
"en", or "en" followed by one or more -/_ subtags of ASCII letters or digits ("en-GB", "en_US", "en-Latn-GB"), case-insensitive, surrounding whitespace ignored |
OFF (English 0.9 calibration) |
A request that runs without the floor records the pii_floor_off_by_language marker in its
request log — the mirror of pii_floor_forced_by_mandate above, so an operator can
always tell from the record alone which calibration a given request actually got. It covers a
masking detector, which loses the PERSON/LOCATION union and the 0.6 threshold, and
equally a presidio detector that blocks or flags with one of those types ticked, which keeps
its own list but loses the threshold and so stops acting on the German name band. It is not
written for a bound detector that ticked neither type, where the floor would have changed nothing.
Accepted / rejected shape. Two layers. At write,
POST /tenants/{id}/gateways,PATCH /gateways/{id}and the guardrail-config import reject alanguagethat is JSONnull, not a string, blank, or contains a control character (400). At use, every stored value keeps the floor except a well-formed explicit English locale (last row above), so a typo or an unknown code can only mask more, never less. To switch the floor off, set exactly"en"(or anen-region such as"en-GB").Behaviour change (this release). A detector whose
languagewas"fr","nl","es","da","deu","german"or any other non-German, non-English value used to run at the English0.9calibration. It now applies the0.6floor and masks more names and places.
When the floor is ON:
- the
PERSON/LOCATIONconfidence floor drops to 0.6; PERSONandLOCATIONare added to the analyzed set when the detector masks — that is, apresidiodetector whoseactionisscrub(the default), and anypii_protectordetector. (custom_piiis a keyword matcher — it has no entity list and no NLP analysis, so the floor does not apply to it at all.) Masking more types than were ticked never refuses a request, so the floor is applied there without asking;- but a
presidiodetector that refuses or flags — anyactionother thanscrub— analyzes exactly the entity types you ticked, and nothing else — unless the request is under a PII mandate, where the floor still wins. A gateway certified as satisfying a mandate must actually analyze the floor types, so the selection cannot bind there. A detector that blocks a request on an entity the administrator deliberately excluded is a control that does not control, so the selection binds wherever it changes what the caller experiences. TickPERSONif you want a blocking detector to act on names. Under a mandate as everywhere else, aPERSONspan that is only a pronoun or role noun is not acted on (see PERSON stop-list); - all other entity types keep their normal thresholds.
Non-English content on an English detector. A detector configured explicitly English
("en", "en-GB", …) normally runs without the floor. When it masks (presidio with
action: "scrub", any pii_protector), the gateway also judges the language of the text being
scanned, field by field, and applies the floor to any field that reads as not English —
German, Danish, Norwegian, Swedish, French or Dutch — the same rule as the configured language,
applied to the content. The judgement is deterministic (common function words plus characters such
as ß, æ, ø) and needs at least two non-English words that clearly outweigh the English ones,
one of them not also an English word (a ß counts as two; ä, ö, ü count as one), so English
text that happens to contain die, hat, van, seg, deg, a citation's et al. or names such as
Han or Sig is not affected. Text it cannot judge — names, numbers, most single words — keeps
the English calibration you chose (a single word with ß, such as Straße, is enough on its own;
a word with ä, ö or ü, such as für or Köln, counts as one of the two signals needed). Each field is judged on its first 4,000 bytes. It errs toward
masking: a short abbreviation that is also a common word in one of these languages (MIT, DES)
can count, so an English text full of them may get the floor. A presidio detector that blocks or flags, and a
detect-only scan, keep the configured calibration (judging the content never introduces a new
refusal on ordinary place names). Because a floored field detects more, it also takes part in the
presidio_partial_scan_failed rule exactly as German content always did: once a field has yielded
personal data, a later field's analyzer failure refuses the request instead of passing it on. (Until
this release only German content was recognised; French, Dutch and Nordic content on an English
detector ran at the 0.9 bar.)
Danish content on an Automatic or English detector. On a masking detector whose language
is Automatic (absent, empty, or "auto" in any case) or explicitly English, a field whose text reads as
Danish is sent to the analyzer as language: "da" instead of "auto" / "en" — the same
value a detector set to Danish sends, so any Danish-specific analysis the analyzer performs for
"da" applies to that field. You do not need to set Language calibration to Danish for that.
Sending "da" never removes a finding. The field keeps exactly the floor it had (0.6 — Automatic always had it, and on an English
detector Danish text already gets it as non-English content). A field "reads as Danish" when the
judgement above calls it non-English and Danish leads it: a word only Danish uses (hvad, noget,
hjælpe, …), or Danish function words (og, ikke, fra, har, blev, på, …) that outweigh
any German, Dutch or French ones, with Norwegian or Swedish words (meg, ikkje, och, inte, …)
not outnumbering the Danish-only ones. Norwegian or Swedish text written only with words Danish
shares therefore also reads as Danish — which can only add findings, never remove any. Forms, tables and lists made of labels and names, with few ordinary words, often cannot
be judged and keep the configured value. It applies per field and on the first 4,000 bytes of each
field, to the request, to the response, to tool results and to the model-generated web-search query. A detector set
to any other language ("de", "fr", "sv", "da", …) is sent as configured, and a presidio
detector's refuse / flag decision on a request, and a detect-only scan, keep the configured value
(its masking passes — such as the final redaction of gateway-composed system-prompt content by a
blocking detector — follow the rule above).
fail_open — accepted shape
fail_open decides what a detector does when its sidecar cannot answer: proceed (true) or
refuse / withhold (false). Each phase has its own default when the field is absent — the
request/response phases proceed (except a prompt_injection detector, which refuses unless it
is set to flag), the tool-result and web-search-query seams withhold — and both true and
false are real operator choices.
Retry before refusing. A refusing (fail_open: false) detector whose sidecar call failed
transiently (no answer, a 5xx) is retried a few times with a short backoff before it refuses.
A failure that a retry cannot fix is not retried: a 4xx, or a classifier that is not
configured — for a prompt_guard detector that includes the platform's inference credential not
being configured, which is recorded as guardrail_error.error_class config (not as a network
fault) and logged for the operator.
What is rejected. A write that introduces a fail_open that is not a literal
boolean — an explicit JSON null, a string such as "false", a number — is rejected with 400
on POST /tenants/{id}/gateways, PATCH /gateways/{id} and the guardrail-config import, naming the
field and the detector. A non-boolean is never an operator choice: every reader treats it exactly
as an absent field (the phase's own default, as above), while the Guardrail Builder's checkbox renders it as one of the two real values
and an export/import round-trips it, so the stored value and what the operator sees would never
agree. A value already stored on a detector is grandfathered (carried through unchanged) so an
existing configuration never becomes unsaveable; correcting it to a boolean repairs it.
Enforcing prompt_injection needs a configured classifier
A fail-closed prompt_injection detector with no classifier behind it blocks every request. So a
write that introduces an enforcing one — type: "prompt_injection", action: "block" (the default), and
not fail-open (action: "flag" and fail_open: true are both fail-open; enabled: false does not exempt a gateway-level detector whose target is request or both (or absent), because tool results are still scanned and withheld; a disabled target: "response" detector is enforced nowhere and is not refused, while a disabled role-policy detector is not enforcing) — is refused while the
platform's classifier is unusable. It applies to POST /tenants/{id}/gateways,
PATCH /gateways/{id}, the guardrail-config import and its dry-run, and to the organisation level
(below).
| Status | Body | Meaning |
|---|---|---|
422 |
{"error": "…", "code": "prompt_injection_classifier_unconfigured", "reason": "credential_unreadable", "switch_on": false, "message": "…"} |
The classifier is unusable. Set fail_open: true, use action: "flag", or have a platform admin fix it. With "switch_on": true the organisation's guardrails_fail_closed switch makes the rule enforcing, so neither helps: turn the switch off or fix the classifier. |
503 |
{"error": "…", "code": "prompt_injection_classifier_unavailable"} |
The classifier setting or the organisation's switch could not be read, or another change to the same organisation's prompt-injection rules or switch was still being saved after 5 seconds (see Concurrent changes below). Retry; nothing was saved. |
reason says why the classifier is unusable. It is the same value the classifier GET returns
(see below):
reason |
Meaning |
|---|---|
missing |
No configuration, or no endpoint or no credential is stored |
credential_unreadable |
A credential is stored but cannot be decrypted on this installation (for example, encrypted with another installation's master key) |
invalid_endpoint |
The stored endpoint is not a valid https:// URL |
invalid_transport |
The stored transport is neither direct nor fleet |
fleet_unconfigured |
The classifier is set to go through the Myra fleet (transport: "fleet"), but this installation has no fleet base URL (MYRA_BASE_URL) or no usable fleet credential |
error and message carry the same English sentence, which names the reason. Neither contains the
endpoint or the credential.
A gateway write is judged with the organisation's current guardrails_fail_closed switch: while it is
on, every prompt_injection detector refuses requests on an unusable classifier, fail_open: true and
action: "flag" included, so introducing one is refused (switch_on: true).
Promotion to production. Only production gateways route, so turning the switch on checks only
those. A POST /tenants/{id}/gateways that changes an existing gateway's purpose from test,
benchmark, archived or disabled to production therefore judges every prompt_injection
detector the gateway will carry as newly introduced, under the switch's current value. These are the
body's config when it sends one, otherwise the stored config. While the classifier is unusable, the
promotion answers the same 422 (with switch_on: true when the switch is on) and nothing is
written: neither the purpose nor the config. A gateway that is already production, a change between
two non-production purposes, a new slug (its config is judged as new anyway) and a create_only
request (an existing slug is a 409) are not promotions. If the stored gateway cannot be read, the
answer is a 503 and nothing is written.
Organisation level. PATCH /admin/v1/tenants/{id} answers the same 422 (or 503) when it
introduces an enforcing prompt-injection rule:
- with
guardrail_baseline: the new baseline has an enforcingprompt_injectionrule the stored one does not (the same per-list counting as above, so an unchanged rule, a rename or an unrelated change passes); - with
guardrails_fail_closed: truewhile it was off: the switch makes everyprompt_injectionrule enforcing,fail_open: trueandaction: "flag"included. Each side is judged with its own switch value, and turning the switch on also checks every production gateway of the organisation. A rule that already refused does not count again.
The check runs after the 400 validation and before the four-eyes hold, so a refused change is
neither written nor held. A held change is checked again when it is approved: if it would introduce
such a rule then, the approval fails (apply_failed, reason prompt_injection_classifier_unconfigured)
and nothing is written. Turning the switch off and clearing the baseline are never refused.
The 400 validation errors above are evaluated first and stay 400. Detectors already stored are
grandfathered: each stored enforcing one covers one incoming enforcing one in the same list, so
renames, unrelated saves and byte-identical re-imports keep working.
Concurrent changes. A gateway write or a guardrail_baseline write that carries a
prompt_injection detector, and turning the organisation's guardrails_fail_closed switch on, each
read what another one writes. So they are saved one after the other per organisation: each holds a
per-organisation lock until it has saved, and right before saving it checks again against the
gateway's or the organisation's settings as they are now. Whichever comes second sees the first one's
result. If the switch was turned on while such a write was waiting, the write is judged with the switch
on, and refused (422, switch_on: true) if it adds an enforcing rule. A rule that is still stored
counts as already there; one that another change removed meanwhile counts as new. If a gateway or a
baseline with such a rule was saved while the switch-on was waiting, the switch-on is refused (422).
This applies to POST /tenants/{id}/gateways, PATCH /gateways/{id}, the guardrail-config import,
PATCH /admin/v1/tenants/{id} (guardrails_fail_closed: true, or a guardrail_baseline with a
prompt_injection rule), and the approval of a held change of each. If the lock cannot be taken
within 5 seconds (another of these changes for the same organisation is still being saved), a direct
write answers the 503 above and an approval stays pending (approve again). Changes without a
prompt_injection detector and turning the switch off never wait for it.
timeout_ms — accepted shape
timeout_ms is the read timeout for a detector's Tier-2 sidecar call. It applies to the four
detector types that make one — prompt_guard, prompt_injection, presidio and pii_protector;
on any other type the field is ignored and not validated.
| value | result |
|---|---|
| absent | the detector type's default (2000 for prompt_guard, 3000 for prompt_injection, 15000 for the PII types) |
a whole number in [1000, 120000] |
used as given |
below 1000 |
400. The call cannot finish, so the detector becomes a guaranteed timeout — and on a fail_open detector the request is then forwarded unchecked while the gateway still reports an active protection |
above 120000 |
400. It would hold the caller open on a guardrail that is not answering |
fractional, NaN, infinite, a string, a boolean, an object |
400 |
JSON null |
400. It is not the same as omitting the field: null is truthy in the gateway's decoder, so it used to reach the socket call and throw |
A value already stored is carried through unchanged, so an existing gateway never becomes
unsaveable over a value it already had — only a write that introduces or changes one is rejected.
Precisely, a write may keep an out-of-range timeout_ms when the same value is already stored on a
detector of the same type in the same carrier, and only as many times as it is stored. That
scope is deliberately name-blind: the detector name is editable on every card while the timeout
field is editable on only one detector type, so a name-scoped rule would have made renaming
such a detector permanently impossible. guardrails and detectors count as one carrier (they are
two spellings of one list, and the UI migrates the legacy key on save); role_policies is separate.
The one shape never carried through is a number that cannot round-trip through JSON (NaN,
infinity) — a config holding one cannot be read back out of the API at all, so carrying it forward
rescues nothing. Independently, the runtime clamps whatever it reads into [1000, 120000] and falls back
to the type default for an unusable value, so a configuration that predates this rule is corrected
rather than obeyed. "Unusable" there is narrower than what the write boundary refuses: the runtime
coerces anything numeric, so a carried-through string like "5000" (or "0x1388", or one padded
with spaces) is read as that number and then clamped, while a boolean, an object, null and NaN
all fall back to the type default. Either way an unusable stored value can never reach the socket
call — which is the half a write-time check cannot deliver on its own, because it never sees a
configuration that was written before the rule existed.
context_prompt — accepted shape and classifier input
context_prompt is read by prompt_guard detectors only. It must be a string or null (clears it); any other
JSON type, or text that is not valid UTF-8, is rejected with 400 on a gateway save, on create and on a
configuration import (including its dry run). A value already stored is carried through, so an existing gateway
stays saveable; at runtime a non-string value is ignored (logged once per detector run, without the value).
The classifier receives [Context: <context_prompt>] followed by the inspected text, as one message of at most
9,000 bytes. A non-empty context is kept (capped at 2,000 bytes); when the text does not fit, the most recent
part is kept behind a ...[truncated]... notice. The cut always falls on a character boundary, and invalid UTF-8 in
the inspected text is replaced by U+FFFD, so the classifier request body is always valid UTF-8.
To analyse every supported entity type, omit entities. On a presidio or pii_protector detector a write
that sends an empty array [] is rejected with 400 (an empty selection is not "none"), and a malformed value —
JSON null, a scalar or object, or an array with a non-string or blank element — is rejected with a
different 400; neither is ever partially applied. A list already stored as [] keeps analysing 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).
{ "type": "pii_protector", "action": "scrub", "language": "de",
"entities": ["PERSON", "EMAIL_ADDRESS", "IBAN_CODE"], "de_recognizers": true }
Operator-visible controls. Both axes are exposed in the gateway Guardrails editor (no raw
JSON needed). The Language calibration select (Automatic → clears language; German →
"de"; Danish → "da"; English → "en" — a masking detector on Automatic or English sends
Danish text as "da" anyway, see Danish content on an Automatic or English detector; a stored value the select has no option for,
such as "fr", shows as Automatic, which has the same floor at runtime) is on the pii_protector card and, on the
presidio card — one shared control, because both detector types read the field identically and
the floor it decides was previously unreachable on the Presidio card altogether. The select writes
the exact value and English keeps the English 0.9 calibration — it does not clear
language. The German ID recognizers checkbox (de_recognizers, off by default) and the
Danish identifiers checkbox (dk_recognizers, off by default) stay on the
pii_protector card alone: guardrails/presidio never reads either. de_recognizers runs
independently of language (structured-ID masking does not require German name calibration,
and vice-versa).
Switching a masking detector from any floor-keeping language to English now asks
for confirmation before it is applied, and the requests that then run without the floor are marked
with pii_floor_off_by_language in the request log — the control used to reduce
protection in one click, silently, and leave nothing behind that could explain it afterwards.
Notes:
injection_thresholdis a confidence in[0,1]. A write to a Prompt Injection detector (create, update, guardrail-config import and dry-run, and the tenant guardrail baseline) is refused, naming the detector, unlessinjection_thresholdis a finite number in0.0-1.0or is left out (the default0.5applies).null, a string (including a numeric string such as"0.5"), a boolean, an object, a negative or above-one value is refused. A gateway create, update, import or dry-run answers400 invalid_config; a tenant guardrail baseline save answers400 invalid_guardrail_baseline. A legacy stored out-of-range value is read as0.5at runtime.score_thresholdand everyentity_score_thresholdsvalue are confidences in[0,1]. A write (create, update, guardrail-config import and dry-run, and the tenant guardrail baseline) is refused with400, naming the detector and the field, unlessscore_thresholdis a finite number in0.0-1.0;null, a string (including a numeric string such as"0.85"), a boolean, an object, a negative or above-one value is refused, and so is anyentity_score_thresholdsthat is not an object of entity type to the same kind of number.NaN,Infinityand a repeated key are refused body-wide. A valid value is kept exactly and sent to the analyzer as written (for example0.6499996stays0.6499996; it is never rounded). Neither field is grandfathered: every write is checked, even an echo of a stored value (a stored valid value is simply accepted again), and no malformed value of either field was stored when the rule shipped. An empty[]or{}forentity_score_thresholdsmeans no overrides and is accepted. At runtime a legacy stored value is read as follows: a numeric string such as"0.85"is read as its number, and any other malformed value is read as absent (the0.7default, or the built-in per-entity table), never clamped to1.0. This runtime reading of a legacy stored value is fail-safe: a threshold of e.g.5(a typo for0.5) would otherwise be impossible for any candidate to meet, so Presidio would return no entities and PII would reach the model unmasked. The gateway editor also blocks out-of-range input at the source and warns when the threshold is set above0.85(the highest built-in entity floor,ORG— above it the global starts filtering entities server-side, including structured high-value PII like email/IBAN/card). A legacy stored out-of-range per-entity override is likewise ignored at runtime (the entity uses the global / high-FP value instead).- The German
PERSON/LOCATIONfloor is a hard floor: a per-entityentity_score_thresholdsoverride may only make it stricter (a lower value), never weaker — so a misconfigured"PERSON": 0.95cannot silently re-open the leak. - The
0.6floor is a deliberate, false-positive-safe calibration and is not lowered further (analysis 2026-07-17): rare real cities scoring0.5–0.6(e.g. "Bremen" 0.564) are not masked — the accepted, bounded trade-off; most real places score≥ 0.7in context, and lowering the floor admits measurable spuriousLOCATIONspans. - A German-configured gateway is calibrated for German text. English text processed
through it may over-redact common words that the NER model scores as names —
this is intentional (a PII boundary errs toward masking). Use a separate
English-configured gateway (
language: "en") for English workloads. - Combine with
de_recognizers: trueto also catch structured German identifiers (Steuer-ID, KV-Nr, …) in one detector. - A
presidiodetector honors the samelanguagetri-state (identical floor), and the same Language calibration select is on its card too. (The German ID recognizers and Danish identifiers checkboxes are stillpii_protector-only, becauseguardrails/presidioreads neitherde_recognizersnordk_recognizers— on apresidiodetector both fields are accepted and do nothing.) languagemust be a non-empty string, or absent. A write that introducesnull, a number, a boolean, an object, a string that is empty or whitespace-only, or one carrying a control character is rejected with400; 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. Arole_policiesdetector has no editor, so a malformed value there must be repaired through the API or a guardrail-config import — the same known limitation the legacyurlfield has. At runtime any non-string resolves to"auto", which is calibrated as German — so a malformed value masks more, never less. Previously a stored"language": nullthrew while the analyzer request was built, the orchestrator recorded a detector error, and afail_open: truedetector then forwarded the request completely unmasked.
Date of birth and age (DATE_OF_BIRTH, DE_AGE)
Two offline recognizers on the pii_protector detector mask a date of birth (opt-in per gateway) and a German age expression. They are pure gateway-side rules with no analyzer call, and they tokenize reversibly like every other PII value: the model sees a token, and the user gets the original back in the answer.
Why a separate recognizer. The hosted analyzer recognizes a date of birth only as a generic DATE_TIME, scored below the 0.9 DATE_TIME threshold. So "geb. 12.03.1948" used to reach the model unmasked. Lowering the DATE_TIME threshold is not an option, because it would mask every date (exam, specimen, report and admission dates) and destroy the timeline the model needs. A date of birth cannot be told apart from any other date by its shape. The label is the evidence.
When it runs. Only on a pii_protector detector where the gateway admin has switched it on: "dob_recognizer": true (in the Guardrail Builder: Date of birth on the PII Protector card). It is off by default; a new or existing gateway does not mask dates of birth until it is enabled. When enabled, it runs:
- independently of
de_recognizers; - not behind a
languagesetting (the labels are German, English and Danish); - regardless of the
entitieslist; - also during an analyzer outage. The analyzer error is still reported, so a
fail_open: falsegateway still blocks; afail_open: truegateway forwards the date of birth masked.
Accepted shape of dob_recognizer. A real boolean, or absent (= off). A write that introduces null or any non-boolean ("true", 1, …) is rejected with 400 on POST /tenants/{id}/gateways, PATCH /gateways/{id} and the guardrail-config import, because the runtime reads only true as on — a malformed value would silently leave masking off. A value already stored is carried through unchanged.
It runs on the request body and on tool results (fetched pages, files, knowledge, MCP output). A value matched here is not exempted by allow_list, which the analyzer applies, not this recognizer. The token's placeholder, if a token ever survives restore, is [date of birth].
DATE_OF_BIRTH is narrow by design (v1). It masks what follows an explicit date-of-birth label and nothing else. Clinical values next to the date of birth stay readable.
What it masks
1. A date-of-birth label followed by a value. The span covers label and value, for example geb. 12.03.1948 → one token.
- Labels (any case):
- German:
geb,geb.,geboren,Geburtsdatum,Geburtsdat.,Geburtstag,Geb.-Datum,Geb.Datum,Geb. Datum,Geb.-Dat.,Geb.Dat.,GebDat,Gebdatum,Geburtsjahr; - English:
DOB,D.O.B.,date of birth,birth date,birthdate,birthday,born,year of birth,YOB; - Danish:
født,fødselsdato,fød.dato,fødselsdag,fødselsår(any letter case,FØDTincluded; after a Danish label only, the gap may also crossd.andi:født d. 12. maj 1948,født i 1948). The bare abbreviationf.is not a label — it is just as often an initial or "female"; - a multi-word label matches across whitespace, including one line break;
- a label must end at a word boundary, so
Gebühr,GebäudeorGeburtsortare not labels; - a label may be the second part of a hyphenated compound (
Patienten-Geburtsdatum,Mutter-Geb.-Datum), exceptborn(first-bornis not a label); bornfollowed bybetween,after,beforeoron ordescribes a cohort and is not a label.
- German:
- Between label and value (at most 32 bytes):
- spaces, tabs and non-breaking spaces;
: = - . _ / *, the en dash–and quotes (ASCII and typographic„ “ ” ‚ ‘ ’ « »), which covers dot leaders,Geb.-Dat.:and Markdown bold;- one cell delimiter
|,;,,or tab; - format hints in parentheses, e.g.
(TT.MM.JJJJ); - the words
am an on the of dem den der im inand German and English weekday names (after a Danish label alsod/d.,iandmandag–fredag;lørdagandsøndagare not read); - one line break, but only when nothing but spaces, tabs, quotes,
*,_,-or>precede the label on its line (Geburtsdatum:↵12.03.1948).
-
The value is masked without calendar validation: a US-order, impossible or compact date after a label is still a date of birth. Accepted forms:
Form Examples numeric, with separators 12.03.1948,12. 03. 1948,12 03 1948,12,03.1948,03/25/1948,12.3.48compact 12031948,19480312year first 1948-03-12,1948/03/12,1948-03-12T00:00with a time a time directly after a full date is part of the value: 1948-03-12T00:00,12.03.1948 14:30with a month name 12. März 1948,12 March 1948,12-Mar-1948,12th March 1948,March 12, 1948,März 1948— month names German, English and Danish ( marts,maj; the other Danish names coincide) full names and abbreviations from a fixed list (Jänner,Feber,Mrz,Sept.included). Any other word ends the value, soGeb.-Gewicht 3500 gorborn Smith 1990is not maskedyear only geb. 1948; a 2-digit year only afterGeburtsjahr/year of birth/YOB(a full date after those labels is masked whole)The value needs a 4-digit group or three numeric groups; a 3-digit group (
1.234,50,1.000.000) is an amount and ends the value. A 4-digit group ends the value, sogeb. 12.03.1948 3 Kinder,DOB 03/1948, 45 kgandgeb. 12.03.1948 02.10.2026 Aufnahmekeep3 Kinder,45 kgand the admission date.
2. * + date. MÜLLER, KLAUS *12.03.1958 (device and letter headers), Hans Müller, * 12. März 1948 and (* 12.03.1948) are masked. The following are not masked:
- a Markdown bullet
* 02.10.2026 …; - bold
**12.03.2024**; - italics
*02.10.2026*; - arithmetic and dosages: a
*after a number, e.g.3*12.03.1958,3 * 12.03.1958,2 * 1000 mg.
3. Rows. In a delimited row (;, |, , or tab) whose first cell is the label (Geb.-Datum;12.03.1948;05.06.1950, | Geb.-Datum | 12.03.1948 |), the following cells are masked up to the end of their value as long as each one starts with a date; the first cell that does not (e.g. Aufnahme) ends the row, so DOB:⇥12/03/1948⇥Admit:⇥10/02/2026 keeps the admission date.
4. Columns. A header line delimited by ;, |, , or tab — a cell that is exactly a date-of-birth label plus at least one other short cell (up to 40 bytes and four words), so a sentence with commas is not a header — followed by its data lines forms a table. The table ends at a blank line or at the next header line that itself contains a date-of-birth label. Lines with fewer than two cells, such as a question after the table, are skipped; a ragged row is fine. A column is masked when both of these hold:
- its header cell is exactly a date-of-birth label (quotes, Markdown emphasis and a trailing
:or format hint are ignored); - at least one of its cells holds a full date (
12.03.1948,12.3.48,1948-03-12,19480312, a month name plus year) inside that cell.
Then every non-empty cell of that column is masked. A column of years only (Geburtsjahr / 1948) has no full date as evidence and is not masked by the column rule. A Markdown separator row is not masked. Geb.-Gewicht, Geb.-Ort and an invoice column Geb. holding only amounts are not date-of-birth columns.
Not covered in v1
These layouts are not recognized. Do not rely on masking for them:
- a value separated from its label by other words:
geboren in Köln am 12.03.1948,Geburtsdatum des Patienten: …,born on the 12th of March 1948; - a 2-digit year after a label other than the year labels:
geb. '48,DOB 3/48; - in a table, a free-text cell containing the delimiter before the date-of-birth column (it shifts the columns of that row);
- quoted CSV with embedded delimiters, and space-aligned (fixed-width) columns;
- in a tool result read in pages, a date-of-birth column on a page that does not contain the header row (the row and label rules still apply on every page);
- formats without a textual label: HL7
PID-7, GDT field3103, and JSON keys such asdate_of_birth/dateOfBirth; - the destructive
presidioscrub detector, and the egress blocks for MCP arguments and fetched URLs.
Known false positives (accepted, reversible)
Geb. used as an abbreviation for Gebühr or Geburt before a date or year is masked. A * used as an abnormal-value flag directly before a date (Hb 12.5 g/dl * 01.10.2026) is masked. A short comma line that reads like a header with a date-of-birth label (DOB, age) followed by comma-separated lines that start with a date masks those first cells. A second table placed directly below a date-of-birth table without a blank line is read as more rows of the first, so its cells in the date-of-birth column are masked; separate tables with a blank line. Examples: an invoice line Geb. 01.01.2025, Z.n. Geb. 2019, and geb. meaning gebunden plus a year in a citation. A table column headed exactly Geb. that holds dates is masked too.
Age (DE_AGE)
German and Danish age expressions are masked as DE_AGE (placeholder [Alter]): 50 Jahre alt, 50-jährig, 50-jährige, im Alter von 50 Jahren, and Danish 50 år gammel, 5 år gammelt, 50 år gamle. The Danish -årig form (50-årig) is deliberately not matched: it describes a duration as often as an age (3-årig uddannelse, 30-årigt lån). The span covers the age expression (for im Alter von 50 Jahren: Alter von 50 Jahren). A bare number or a year (1950 Jahre) is not an age. This recognizer runs whenever the request is handled under the name/place floor (any detector language except explicit English, non-English content on an English detector, or a PII mandate), also during an analyzer outage. It is not behind de_recognizers.
Name-recall propagation
The NER model's PERSON recall is case- and repetition-sensitive: it reliably
catches a capitalised first mention ("Anna") but can miss a later lowercase or
repeated occurrence ("anna") of the same name in the same text. To close that
under-redaction gap, a pii_protector detector automatically propagates every name
the model already confirmed as a PERSON to its other whole-word,
case-insensitive occurrences in the same message, masking them with their own
(case-exact, reversible) token.
allow_list_matchmust be"exact"or"regex", or absent. A write that introduces or changes it to anything else —"partial"in particular, which the Guardrail Builder offered and this page once documented — is rejected with400onPOST,PATCHand the guardrail-config import; a value already stored is carried through. The analyzer answers HTTP 500 to any other mode, which the detector reports as an error and afail_open: truedetector then turns into an unmasked pass — so at runtime an unsupported value is coerced to absent, which is the analyzer'sexactdefault (narrower allow-listing, i.e. more masking). Onlypii_protectorsends the field;presidiois allow-list-blind and a value stored on one is inert.allow_liston apresidiodetector is refused. That detector builds its own analyzer request —text,language,entitiesandscore_threshold, nothing else — so an allow list on it was never sent and never honoured, and on anaction: "block"detector the request was still refused on the value the operator had explicitly exempted. A write that introduces the field on apresidiodetector is rejected with400onPOST,PATCHand the guardrail-config import; a value already stored is carried through, dropped on the next save from the Guardrail Builder, and stripped from an exported guardrail-config file so the file stays importable onto another gateway. The field remains valid and honoured onpii_protectorandcustom_pii.- This is always on — it needs no configuration and changes no score threshold.
- Only a string the model already classified as a name is propagated, and never onto an occurrence the PERSON stop-list (below) identifies as a pronoun or role noun, so a span the stop-list dropped is never re-masked through propagation. A name the text uses mid-sentence ("Herrn Du") counts as a name everywhere in that text, so it does spread to its lowercase forms.
- It is bounded to whole-word matches, so a name embedded in a larger word (e.g. "anna" inside the German word "Annahme") is left untouched.
- Like the German calibration, it errs toward masking: if a confirmed name also appears as a common word in the same message, that occurrence is over-redacted (and restored on the response) rather than leaked.
Name parts. A name the model confirmed in full also protects its parts: after
"Mette Kjærgaard Nielsen", every other "Mette" and "Nielsen" in the same text — and
the one-word genitive "Mettes" (not for parts ending in s, x or z) — is masked too
("Anna Weber … Frau Weber"). Up to 100 parts per text are propagated, taken from the longest names first. A part is
a capitalised word of at least two letters, without digits, of a multi-word name;
titles (abbreviated or spelled out: Dr., Professor, Doktor, Advokat),
initials, particles (von, de) and the words of the PERSON stop-list are never
parts. To stay precise,
a part matches only its exact capitalised spelling, and when the text also uses the
part's lowercase form as an ordinary word ("will", "storm", "have" — not inside an
e-mail address, URL or other long token), a part at the start of a sentence is left alone ("Will Smith …
Will you send it?"). Not covered:
lowercase or ALL-CAPS follow-ups of a part ("mette", "NIELSEN"), names written
entirely in lowercase, non-Latin scripts, names with an inner capital ("McDonald"),
and one-word parts in another message (see "Across messages" below). The propagation errs toward masking: a capitalised
ordinary word that equals a part is masked mid-sentence — a noun ("der Koch" after
"Anna Koch"), a month or a place ("in May" after "May Johnson", "to Paris" after
"Paris Hilton"), a different word that equals a part plus "s" ("Jens" after "Jen
Holm") — and so is a capitalised part inside an e-mail address or URL that the model
did not mask as a whole ("Mette.Nielsen@…").
Across messages (request phase). A multi-word name the model confirmed in
one message or request field is also masked, case-insensitively and whole-word, in
later fields of the same request: after "Anna Schmidt hat angerufen" and "ok", the
lowercase "was wollte anna schmidt?" is masked and restored on the response. Only the
full value is carried, and only when every word passes the PERSON stop-list and name-part
checks and at least one word is not an ordinary lowercase word of English or German
(checked against a bundled dictionary-derived word list). A name made only of common
words ("Rich Brown", "Summer Rain", "Ernst Lange", "Bill May") is therefore not carried, because
its lowercase form turns up in plain prose by chance; "Anna Schmidt", "Yasmin Aydin" and "Frank Koch"
are carried. If the bundled word list cannot be read, nothing is carried (fail closed) and an error is
logged. Carry stays inside one request and is bounded by a per-request work budget and at most 100
carried names (measured cost with 100 carried names on a ~6 MB request body: 0.07-0.16 s of CPU); past either limit later messages are not carried (one warning is logged per request
and limit). Not covered:
one-word names and name parts in a later message ("anna", "schmidt"), propagation to
earlier messages, lowercase single-word follow-ups, tool-result and system-prompt
NER, the presidio detector, and the response phase. The remedy for those remains a
custom_pii keyword.
Limitation — this is propagation, not new detection. A name the model never scores above the confidence floor in any form (an unusual/non-Western name, a typo, or text where the only occurrences are lowercase) is still missed; that is bound by the NER model and its threshold, not by this gateway logic.
Deterministic remedy for known names. For names you already know (employees,
frequent contacts) that the NER model scores below the floor, add them to a
custom_pii keyword detector on the gateway (or, per end-user, the My-PII
keyword list). A custom_pii keyword is matched literally, whole-word, and
case-insensitively by default — so it masks a lowercase-only name (anna) or an
unusual/typo'd spelling the NER model would miss, at any confidence and before the
request leaves the gateway, regardless of the PERSON floor. This is the intended
lever for the residual above; it does not depend on Presidio detecting the name.
PERSON stop-list (pronouns and role nouns)
The NER model also tags pronouns and generic role nouns as PERSON — the Danish
"du" on most of its occurrences, "Borgeren", German "Ich" or "Der Patient", English
"I", "someone" or "my friend". Both PII detectors that read the analyzer drop such a
PERSON span before they act on it:
- a
pii_protectordetector does not mask it, so a letter written in the second person reaches the model with its "du"/"you" intact, and the pronoun never seeds name-recall propagation; - a
presidiodetector does not act on it with anyaction:blockdoes not refuse the request over it ("Kan du hjælpe mig?" is answered),scrubdoes not replace it with<PERSON>, andflagdoes not record it. A real name in the same text still refuses, masks or flags as before. This holds on the request and the response phase and for tool results.
It is always on and needs no configuration, also under a PII mandate. It applies to
PERSON spans from the analyzer only — never to a value the user selected for masking
(Mask on Demand), and not to any other entity type. The word list and the rules below are
the same for both detectors. The word list is closed and covers Danish, German and
English (it does not depend on the detector language):
- Function words — personal, possessive and reflexive pronouns, articles,
determiners and connectors (du, dig, din, vi, hun, jeg; ich, du, sie, wir, der, die,
ein; I, you, he, she, we, my, your, the, someone, …). Not listed:
hans,han,min,sig— common names even when typed in lowercase. - Role nouns — only words the model was observed tagging as a person, with their inflected forms: borger(en), sagsbehandler(en), ægtefælle, Patient, Kläger, Sachbearbeiterin, Antragsteller, client, applicant, friend, people, and account / workplace roles in product prose: admin, administrator, employee, member, manager, staff, user, Nutzer, Benutzer, Mitarbeiter(in), Mitglied, Kollege/Kollegin, Ansprechpartner, Inhaber, Verwalter, …
A span is dropped only when every word in it is on the list, so a span that contains a name ("Wei Du", "Frau Han", "Der Patient Müller") is always masked whole. Context decides the rest, always toward masking:
| Occurrence | Treated as |
|---|---|
Lowercase listed word (du, din, borgeren, my friend) |
not a name |
I anywhere |
not a name |
Capitalised pronoun/article at the start of a sentence, followed by a lowercase word or a listed role noun (Du kan …, Der Patient …, He said …) — but not by a word that continues a name (He et al., Du von …) |
not a name |
Capitalised role noun after an article or possessive (der Kläger, The Chairman), or at the start of a sentence before a lowercase word (Borgeren har …) — not before a comma or a capitalised word (Arzt, Thomas, Notar Peter) |
not a name |
Capitalised listed word mid-sentence, at the end of a line, or before a capitalised word (Herrn Du, Du Wei, a signature line Vi) |
name — masked |
A capitalised form that is a common given name or surname (Else, Das, De, Din, Mine, Man) |
name — masked |
A capitalised role noun that is also a surname (Kunde, Partner, Person, Friend, Child, Member, Manager, Staff, Kollege, Verwalter), with or without an article (Der Kunde, that Partner, van der Kunde) — only lowercase (my friend) counts as the role |
name — masked |
Any listed word after a title or salutation, also across a non-breaking space, a line break or a title chain (Frau han, herrn du, Hr. Du, Frau Prof. Dr. h. c. du) |
name — masked |
A listed word directly next to another masked name, separated only by spaces or by og/und/and/or (ruf wei du an, Du og Wang) |
name — masked |
A lowercase object pronoun (mich, mir, dich, dir, me, them, mig, dig, os) in front of a connector and a name (von mir und Stefan) |
not joined to the name: the pronoun is not a name, Stefan is masked. Directly next to a name (ruf wei mir an), after a name (Stefan und me) and capitalised (Mir und Stefan) it stays masked |
You or Ich as the very first word of the text or of a message (right after a User: / Assistant: speaker label), directly followed by : (You also by ,), a space (not a line break) and a lowercase word (You: hello, You, are …, Ich: hallo) |
not a name |
You after a Hello that opens the text (or a message, right after a speaker label), followed by a full stop that ends the sentence (Hello You. You are not my assistant.) |
not a name |
The same words in any other position or case (Hi You: hello, YOU:, You: followed by a capitalised word, a word that does not start with an ordinary lowercase Latin letter (a digit, Cyrillic, Greek or Chinese, and a few letters such as ß or ș), a role noun or a name particle), after a title (Frau You: hello), next to another masked name, or when the text uses the word as a name elsewhere |
name — masked |
ALL-CAPS or mixed case (DU, dU) |
name — masked |
A word the same text also uses as a name — after a title or salutation, or capitalised or in capitals mid-sentence (for Else, Mine, Man … anywhere), not inside a run of capitalised words such as Den Europæiske Socialfond or a heading HVIS DU HAR, and for a role noun not after an article (… Herrn Du angerufen. du hat …, Herrn DU) |
name — masked |
A word of another name the model found in the same text, or of a value already masked as a PERSON earlier in the request or conversation, in any capitalisation (Wei Du … Du hat …, WEI DU earlier → Du hat … later) — for a word whose capitalised form is a common name (Else, Mine, Kunde) also in lowercase (Else Meyer … ruf else zurück) |
name — masked |
Speaker labels. User and Assistant at the start of a line, written lowercase or
capitalised and followed directly by a colon (User: …, Assistant: …, user: …), are
transcript labels, never a name — the labels this product writes when it sends a model a
transcript of the conversation (the chat's follow-up suggestions and automatic title, the
gateway's conversation compaction). Such a label is decided by its shape alone: other uses of
the word in the same text (User.find(id), "Google Assistant") do not turn it back into a name.
The list is closed — any other word used as a label stays masked (Anna:, Arzt:, Notar:,
Kunde: — a chat export labels lines with names). Not a label, and therefore judged by the rows
above: a label with anything between the word and the colon (User :, a non-breaking space, a
full-width :), in capitals (USER:), not at a line start (Contact User: …, a quoted > User:),
after a title or salutation (Frau⏎User:), or as part of a longer span (User: Max Mustermann
is masked whole).
A colon or semicolon does not start a sentence (Navn: Du is a form value), and
neither does the dot of a title, abbreviation or initial (Dr., Hr., med., J.).
Miss, Sir, Lady, Lord and Dame count as a title only when capitalised.
A PERSON value counts as evidence for its words up to 256 bytes and 32 words; a longer
value (a whole paragraph tagged as one name) gives none.
Residual risk — a name that is spelled like one of those object pronouns, in lowercase, directly in front of a connector and a name (os und Stefan) is no longer masked through that neighbour. Likewise, a name that is identical to a listed word and appears only
where the rows above call it the common word: a surname alone at the start of a
sentence before a lowercase word (He called back.), or a given name typed only in
lowercase (tell else to call), with no other use of it as a name in the same text
or in an earlier message, and no capitalised title in front (a lowercase miss or
sir is not read as a title). Messages are processed in order, so a mention in a later
message of the same request does not protect an earlier one. Add such names to a
custom_pii keyword detector (see above) to mask them at any position. The same holds for a
person literally named "User" or "Assistant": a line-initial User: / Assistant: label is never
masked and never spreads masking to other mentions of the word, so such a person is masked only
where the model itself tags them.
The same holds for a person whose name is spelled You or Ich: written in exactly the placements of the You: / Ich: / Hello You. row, with no title, no other masked name next to it and no other sign of a name in the text, it is not masked. The start of the text is the start of the field, or of the scanned window of a long tool result. A speaker label at the start of a line (User:, Assistant:; written User/user, Assistant/assistant, not in capitals or mixed case) does not count as text: the word behind it is at the start of its message, so the follow-up suggestion request, which sends the last question and answer as User: … and Assistant: …, treats User: You: hello exactly like You: hello. The You: / Ich: / Hello You. row needs exactly one space after the label's colon. The sentence-start rule (Du kan …) walks back over any spaces, tabs and opening quotes to the label's colon, exactly as it does at the start of the text, so User: Du kan …, User:\tDu kan … and User:Du kan … count as a sentence start. A prefix that is no label (Frau User:, Name:) gets neither rule. The sentence-start walk looks back at most 64 bytes: behind more than about 60 spaces after the label it does not reach the colon, so the word is not treated as a sentence start and stays masked (the safe direction). In a text that opens with Hello You., that You does not count as a use of the word as a name, so a later you in the same text is not protected by it either.
For a presidio detector, "an earlier message" means: a value a pii_protector detector
already masked as a PERSON in this request or conversation (also when that masked value
stands next to the word, separated only by spaces or by og / eller / und / oder / and /
or), or a
PERSON span a presidio detector kept earlier in the same request — an earlier
message, the request phase before a tool result, an earlier window of a fetched page.
Values masked by a custom_pii keyword detector, and values of other entity types, are
not evidence. A name that a
presidio scrub already replaced with <PERSON> in an earlier, stored turn is no longer
in the text and cannot protect anything. A window of a long fetched page that starts in
the middle of a sentence has its first word read as the start of a sentence.
If the text is not valid UTF-8, the stop-list is off for that text and every PERSON
span the model found is masked, refused or flagged. The same holds when the request's
record of already-masked values is unreadable.
Out of scope — open-class phrases are not on the list and stay masked when the
model tags them (din eventuelle ægtefælle, Managing Director, behandelnden
Arzt); organisation names the model tags as ORG (Kommunen, Jobnet) are
unaffected.
Multi-word terms also match common separator and case variants. A protected term of
two or more words (e.g. Project Orion) is matched not only as the exact phrase but
also in its snake_case (project_orion), kebab-case (project-orion),
concatenated / PascalCase / camelCase (ProjectOrion, projectorion) and re-spaced
forms — case-insensitively unless the detector sets case_sensitive. This closes the
exact-match bypass where a user (or a tool result) wrote the term in a different casing or
with a different separator. The generated variants are always matched whole-word (so
ProjectOrion is masked but myProjectOrionX is not) and all variants of one term share a
single reversible [MYRA-CUSTOM:…] token, restored to the canonical configured term. A
term is expanded only when it has ≥2 words, each ≥2 characters, ≥6 characters total —
single-word and trivially short terms (Go To) keep exact-match behaviour to avoid noise.
Accepted input is any keyword string, including non-ASCII; a keyword that is not valid
UTF-8 degrades safely to exact-match only (never a malformed or over-broad variant).
Documented limits of the keyword matcher. The matcher operates on text, so:
- Concatenated/hyphenated dictionary words. A length threshold cannot tell an
identifier from a real word, so a protected term whose words concatenate or hyphenate into
a common word (
Data Base→database,Log In→login) will also mask that word wherever it appears — including inside a tool / RAG result the model needs for grounding. Choose distinctive multi-word terms, or expect the common form to be masked too. - Splitting across messages. If the words of a protected term are sent in separate messages (never adjacent in one field), no single field contains the term, so it is not masked at the request phase — masking individual generic words would over-mask. If the model then reconstructs and emits the term, the response sweep tokenises it.
- Context inference. Masking replaces the term, not the surrounding facts. A model can still reconstruct a masked term from uniquely identifying clues left in the user's own text (a proprietary language + database + version fingerprints a product; a unique penalty structure fingerprints a regulation). Generic descriptions and arbitrary identifiers stay safe. This is inherent to a text matcher over un-maskable context; when masking a well-known term, sanitise the identifying context clues too.
Stored system-prompt content. The memories, profile and stored instructions the gateway composes into a chat's system prompt are masked with the request-phase
detectors before they are composed (instructions with the system-text scope; block detectors
redact instead of refusing; an engine outage refuses the turn unless fail_open: true outside a
mandate) — see PII Protector — Stored content in the system prompt.
A [MYRA-CUSTOM:…] token's id (k + 7 hex) is content-derived per conversation and user (no longer a
per-request counter).
Tokens the model writes without their brackets. A model sometimes drops the square brackets
and writes MYRA-CUSTOM:<id> or MYRA-REDACT-<TYPE>:<id> as plain text. The answer path treats
these bare forms like the bracketed ones. Neutralization matches case-insensitively, but a token is
restored only when it matches the issued token exactly (a re-cased token becomes a placeholder
instead). A MYRA-REDACT-… type may use letters, digits and underscore, and the match is bounded to
the length the gateway can hold back while streaming (an optional trailing ] is taken along): a token that belongs
to this conversation is restored to the original value, and any other bare token is replaced by
[redacted] (a custom keyword) or its typed placeholder (a MYRA-REDACT-… token) — in streamed and
non-streamed answers alike. A known token directly followed by further letters or digits is a
different identifier: it is not restored and becomes [redacted] followed by those characters.
Ordinary prose such as myra-custom:foo is left untouched.
A bare token whose type is outside the grammar (longer than 63 bytes) stays plain text. On buffered
(non-streamed) answers the custom-keyword restore runs before the PII restore pass, so a custom value that
itself contains token grammar may be neutralized by the second pass.
Restore and neutralization happen in one pass over the answer, streamed or not: a restored
original value is written out as is and is never scanned again (except on buffered answers, where the
custom-keyword restore runs before the PII pass, see above), so a value that itself contains
token-like text is delivered verbatim. A MYRA-REDACT-<TYPE> type is at most 63 bytes (letters, digits,
underscore). While streaming, the gateway holds back only a bounded tail (the longest possible token),
and a stem that never completes is released as ordinary text. On the raw JSON stream the gateway
does not decode JSON escapes inside a token (a model does not escape ASCII token characters); an
escaped token is therefore not restored, but a bare token inside it that is in the token grammar is
still replaced by its placeholder.
Custom keywords are also masked on tool-result egress. A configured
keyword that arrives back through a tool result — a read_file of an uploaded
document, knowledge / RAG retrieval, a web_search result, a fetch_url page, or an
MCP tool result — is re-masked with the same reversible [MYRA-CUSTOM:…] token
before that result is dispatched to the model, exactly as the request phase masks
it (the two paths share one keyword tokenizer and one per-turn token map, so a keyword
seen on both maps to one token and is restored once in the final answer). This closes
a leak where a custom keyword returning through any tool result previously egressed to
the provider in clear. The masking is fail-closed: because a tool result is
untrusted content, a fault while masking it withholds the whole result behind the
[tool result withheld: PII scan unavailable] placeholder rather than forwarding the
raw keyword. (Accepted input: any tool-result string; a malformed / empty / non-array
keyword list is treated as "no keywords" — the same inert result an absent list gives,
consistent with the request phase.)
Why the English PERSON floor is not simply lowered to catch these. A live
GLiNER sweep of 30 must-mask names against 130 benign German/English business
prompts (tests/false_positives/person_floor_analysis.py) found no confidence
floor that is false-positive-free: at every gate the model masks capitalised
common-noun role terms (Der Kläger 0.99, General Manager 0.93) as PERSON, and
lowering the English floor from 0.9 to 0.6 multiplies English false positives ~7×
while recovering only two of the sub-floor names. So the floor stays calibrated per
language (German 0.6, English 0.9), and the keyword lever above — not a blind floor
drop — is the deterministic answer for known low-confidence names. For German
deployments, keep language unset / "auto" / "de" (an explicit "en" opts into
the 0.9 English floor and drops sub-0.9 German names).
Earlier conversation turns (block on request)
For a request-phase detector with action: "block", the gateway blocks only when the last user message matches. Applies to every client (chat completions, Responses, Anthropic Messages). See Guardrails for the semantics per detector type.
Accepted conversation shapes. The conversation is the messages array, or the Responses input array when messages is absent. A messages value that is present but not an array of messages is a block; it never falls back to input. A string input, a prompt, a body without a user message, or a first-turn request has no earlier history, so a match blocks as before.
Tool-call arguments (PII Protector, Presidio and Custom PII masking). This applies to the masking detectors, not to block detectors: for a masking detector, the arguments of an earlier assistant tool call (messages[].tool_calls[].function.arguments, the legacy function_call.arguments, a Responses function_call item) that is one valid JSON object has each string value masked in place; keys and numbers stay byte-identical. Any other non-empty arguments string is masked as whole text. Personal data in an object key is not masked; on a Presidio detector a request whose only text is such a key is reported as unscannable and refused under a PII mandate. For block detectors, see What is removed below.
What is removed. Messages before the last user message, other than system and developer messages. A tool result keeps its tool_call_id / tool_use_id / call_id; only its content changes. An Anthropic tool_use block whose input carries the match has its input emptied to {}; its id and name are kept, whether or not the message has other blocks. An OpenAI tool_calls[].function.arguments value, the legacy function_call.arguments and a Responses function_call item's arguments that match are emptied to "{}" (ids and names are kept), exactly like an Anthropic tool_use input; the request continues when the rest of the history is clean. This emptying applies to tool calls your own client sent. A language match in your own earlier turns still blocks.
The exchange the gateway re-inserted. For an earlier file edit in a Workspace chat the gateway can insert a tool exchange of its own into the request (see Earlier file edits). A history-only block hit that involves this exchange never refuses the turn by itself:
contains_codeandjailbreakdetectors set toblockleave all of the re-inserted exchanges out of the request first.- Every other per-message detector whose verdict is
block(including a scrub detector whose masking failed) resolves the hit in the exchange first:keyword,regexandpresidiomask it, the others replace it with the placeholder. It leaves the exchanges out only when today's mask or removal cannot resolve the hit and the unresolved hit includes the re-inserted exchange (for example a JSON number inside the re-inserted tool call, or text that cannot be re-encoded after masking). - The
languagedetector never counts the exchange: its verdict is the one the request had without it. - The hit may also lie in your own earlier turns. Those are masked or removed (replaced by the placeholder) as described above and the turn is answered; an earlier turn of your own that can be neither masked nor removed refuses the turn.
- A hit in the new message still refuses the turn.
- The turn is refused, not forwarded unchecked, when the request cannot be checked within the gateway's limits (see Bounds), when the request without the exchange cannot be built, or when a detector call fails (also with
fail_open).
Bounds. At most 24 detector calls and 3 seconds per request, across all detectors. Beyond either, the request is blocked.
Residual. The Gemini-native request shape (contents) is not decoded for history and blocks on any match. A match split across a removed turn and a kept turn is not detected as a single match. A direct-API client can wrap a forbidden question in a tool_use / tool_result pair so that it moves into history: it is masked or removed and never sent to the provider, but the request is not refused.
Audit. The request log's meta.guardrail_history_removed is an array with one object per detector that removed history:
index is the 0-based position in the conversation array; action is masked or dropped. The matched text is never included. inserted (always removed) is present when the gateway left its re-inserted exchanges out of the request (see The exchange the gateway re-inserted); entries is empty when the hit lay only in those exchanges, and index then counts positions in the conversation as sent to the provider, that is, without them. The marker is capped in size; when entries were cut to fit, the object carries "truncated": true.
Web-search query egress (fail-closed)
When a gateway runs web search, the search query the model generates is itself an outbound string sent to a third-party search provider (the configured provider: Brave or linkup). A model can put personal data into that query, which would otherwise leave the gateway unmasked — bypassing the request-phase PII layer entirely.
The gateway removes personal data from the model-generated query, at the trust boundary,
before it egresses, in two passes. Protected terms (the signed-in user's personal keywords and
the keywords of the custom_pii detectors that apply) and redaction placeholders are removed
on every gateway, with or without a pii_protector detector. Detected personal data (names,
numbers, addresses) is removed only if the gateway has a pii_protector detector:
- No PII detected → the query is sent unchanged.
- PII detected → each detected value is removed from the query (it is not replaced
by a token), together with every protected term (the signed-in user's personal keywords
and the keywords of the
custom_piidetectors that apply) and every redaction placeholder the model wrote into the query — bracketed or bare, in any letter case. The remainder is collapsed (whitespace and dangling punctuation tidied). After removal, leftover words that contain no letter or number (punctuation, lone combining marks, symbols, emoji) are dropped; if nothing with a letter or number remains, no search is sent and the tool reports that it was skipped. The search provider receives only this cleaned query. This applies to every third-party egress of the query — the search request and the optional weather lookup — and to the query as it appears in the operator logs, theX-Web-Search-Queryresponse header, and the search-result trace. - Nothing meaningful left (the query consisted only of protected terms or placeholders)
→ no search is sent. The model receives a structured "search skipped" tool result
and the skipped query does not count against the turn's search allowance. The gateway
log carries a
web_search_query_skippedline with the reason, never the query. - Query refused by a rule (a keyword rule of the gateway, a protected-keyword match, a personal-data
rule, or the PII-mandate gate) → no search is sent, and the model is told the real reason in the
refusal text itself, for example "matches a protected keyword or pattern of your organisation" for a
keyword rule. It is never reported as "PII scan unavailable" or as an injection block. The reason
comes from a closed set; an unknown reason reads as the generic
[query withheld]. The matched keyword is never named. - PII scan unavailable (the analyzer is down, the time budget is exhausted, or the
scan errors) on a detector that is not
fail_open— or, under a PII mandate, on any detector (the mandate outranks the flag here; see When the masker is down) → the gateway fails closed: the raw query is not sent to the provider, and the model is told the search was withheld. Data is never leaked to satisfy a search.
Accepted / rejected shape. The query is accepted as a non-empty string. A query
carrying detectable PII is accepted but has the PII removed before egress; a query
that cannot be scanned (analyzer outage) is rejected for egress (the search is
withheld) unless no PII mandate is in force and the detector explicitly opts into
fail_open — that forward is recorded on the request as a guardrail gap
(guardrail_degraded / pii_scan_degraded / guardrail_error).
Scope. The fail-closed guarantee is provided by a non-fail_open pii_protector
detector — the only detector type that reliably fails closed. A gateway without such a
detector does not pseudonymize the query (a presidio scrub detector fails open on
outage and cannot give a third-country guarantee). Under a PII mandate — a
pii_mandatory project, a forced agent invoke, or a tenant with masking enforced (an
unresolvable project tier blocks every egress tool outright, one step earlier) — a gateway
with no pii_protector therefore withholds the search rather than send the raw query (keyed on the
mandate from any source, not only the tenant flag, and on both search engines with one
wording: "this workspace requires personal-data masking, but no reversible PII masker is
configured"). The local-only model-leg exemption does not reach this gate: the query's bytes
leave for a third party. The data flow leaving the gateway to the search provider is therefore: model query
→ pii_protector tokenization → provider sees only tokens, or the search is not sent at all.
(This section covers the two model-generated web-search paths; the admin playground search
box sends operator-typed text and is out of scope.)
Injection scanning of tool results
Tool results — the content a server-side tool leg fetches and fuses back into the next
model call (read_file, knowledge/RAG passages, web-search results, MCP tool output,
agentic fetch_url, code-interpreter stdout) — are untrusted third-party / model
content. An indirect prompt injection embedded in such content (a poisoned document, a
hostile web page) would otherwise reach the model unscanned, because the request-phase
detectors run on the user's prompt, not on tool output.
This includes text extracted from a fetched document (PDF / DOCX / XLSX pulled by
fetch_url / agentic_fetch; see Web search → Document fetch). The raw document bytes are untrusted: they are magic-byte-sniffed to an allow-list, never executed, and parsed only by the sandboxed extractor; the resulting text then passes through this same tool-result trust boundary (injection scan + PII masking) before it reaches the model. On the agentic_fetch inner-model leg the extracted document text is masked/scanned before the inner model, and under a PII mandate (a pii_mandatory project, a forced agent invoke, a tenant with masking enforced) on a gateway with no reversible masker the document is withheld outright (fail-closed). The document goes to the inner model, so this is a model-leg decision: a wholly-local inner model is not a mandate case (nothing leaves the estate, and the inner request phase skips masking there too), and on a local-only gateway of an enforcing tenant the exemption applies — the same leg rule the tool-result seam uses. Inside an agent-shaped run the inner leg is never treated as local and the run is not exempt, so the document is withheld there under a mandate. A scanned/no-text-layer PDF read via OCR is additionally lower-confidence and reaches the model labelled as such (may contain transcription errors — verify figures/dates against the source), so it is never presented as authoritative.
When the gateway web search tool is offered, fetch_url / agentic_fetch are now also offered so the model can open a link it found in the search results (co-arm). The URL is then an untrusted model choice driven by untrusted search-result content, so every such fetch stays gated by the SSRF/redirect guard, the outbound PII/secret exfiltration check (fail-closed), the refuse-on-structured-PII URL gate (armed on a PII-active gateway or under a PII mandate from any source), and this tool-result injection scan on what comes back; a bounded per-turn fetch cap limits fan-out.
If the gateway has a jailbreak detector, the gateway now runs that detector's
matcher over each tool result as well, at the same trust boundary where tool-result
PII masking happens, before the result re-enters the model. Which jailbreak detectors
apply is decided exactly as on the request phase: a detector with target request,
both, or absent applies (a tool result is the next leg's model input); a
response-only detector does not.
Evasion handling. Before matching, each result is normalized and decoded so the
common lightweight obfuscations do not slip an injection past the matcher: whitespace runs
are collapsed, zero-width / BOM characters are handled both as intra-word noise (stripped)
and as word separators (mapped to a space), and the text is expanded through the same
evasion-decode used by the exfiltration egress guard (percent-decoding incl.
double-encoding, ROT13, and per-token Base64 / hex). This decode expansion has fixed
bounds: it is single-layer (one Base64/hex decode, not nested base64(base64(…))) and
skips any single encoded token longer than 4 KB; the scan itself covers each result
up to the scan bound (see "Scan bound" below). An injection that
is nested-encoded, hidden in one very large Base64 blob, or placed entirely beyond the
scan bound is therefore not decoded/scanned.
Action. The detector's own action decides the outcome, per gateway configuration:
-
action: "block"→ the offending result is withheld: its content is replaced with a neutral placeholder before fusion, so the injected text never reaches the model. The rest of the turn proceeds. The placeholder names the real cause, so neither the model nor the operator is sent chasing the wrong problem:Cause What the model receives Injection detected (jailbreak keyword match, or the prompt-injection classifier's verdict) [tool result withheld: blocked by an injection guardrail]Prompt-injection classifier unavailable under a fail-closed blockdetector[tool result withheld: prompt-injection check unavailable]PII scan unavailable [tool result withheld: PII scan unavailable]Blocked by another gateway guardrail [tool result withheld: blocked by a gateway guardrail]Any other withhold [tool result withheld]The refusal text the gateway itself writes when it refuses an outbound call (a web-search query, a URL fetch, an MCP tool call) is not scanned again as if it were page content, and it does not mark the conversation as carrying untrusted content. Only text the gateway wrote is exempt, matched exactly within the same request: a text that differs by any byte, or the same sentence in another request, is scanned as usual. An identical copy within the request is the gateway's own text, so skipping it is harmless.
A scan-exempt refusal embeds only these places: the fixed word
query;url:<host>(host characters[a-z0-9.-]only, at most 253, otherwise the bareurl);tool_args:<name>(the tool name, closed format[A-Za-z0-9_.:-], at most 64 characters, otherwise the baretool_args); and, for an MCP tool, the connector's display name as written by whoever created the connector (MCP_AUTHOR, members included; free text of at most 120 bytes, not injection-scanned inside this text). It never embeds the URL, the query or a tool argument value. The PII and keyword scans still run on it.During a turn, a result already replaced by one of these placeholders is not scanned or relabelled again; stored conversation records are re-scanned as text.
-
action: "flag"(the default) → observe-only: the match is recorded but the result content is passed through unchanged. An injection in a flagged gateway therefore still reaches the model — setaction: "block"for enforcement. On a top-level turn the flag also queues a moderationreview_item(trace reference + detector name only — never the matched content; see Agents → moderation queue).
Every withhold also counts one occurrence into the deduplicated model-error triage row (class
prompt_injection, category guardrail_policy): queued for the triage agent, but not paged as an
incident, because a deliberate withhold is the guardrail working as configured.
Accepted / rejected shape. A tool result is accepted as a string. A result that
matches an applicable block jailbreak detector (in its raw, normalized, or decoded
form) is rejected for fusion (withheld behind the placeholder); all other results
pass through. A withheld result is never additionally PII-processed.
Scan bound. The scan covers the whole of each result going back to the model, up to
96 KiB (the 80 KiB tool-result cap plus 16 KiB headroom); a document fetched by the
agentic fetch is scanned up to its own input limit (about 200 KiB). Bytes past the bound
are unchecked: under a fail-closed block prompt-injection detector they are cut and replaced by a notice
that they were not checked for prompt injection, otherwise they pass through; one
aggregated warning line is logged. A tool result stored in a conversation record is
scanned over its first 16 KB only.
Scope and limitations. The matcher is the jailbreak keyword list (the built-in
set, or the detector's custom keywords when configured) — a literal-phrase tripwire. It
catches known jailbreak / injection phrases and their encoded/whitespace-obfuscated
variants; it does not catch paraphrased, non-English, or homoglyph-substituted
injection. Because it is a keyword match, benign content that legitimately quotes such a
phrase (for example security documentation, or a user's own note containing
"ignore previous instructions") will also be withheld under a block detector — the
accepted cost of the tripwire. Operators tune this by choosing flag vs block and by
supplying a custom keywords list; each match is logged with the tool index and the
matched keyword.
Continue after Stop and the request-phase classifier
A request-phase prompt_injection detector does not classify the platform's own Continue instruction when the
request is a verified Continue turn: the newest user text equals one of the platform's Continue instructions byte
for byte, x-aig-conv-id and x-aig-parent-msg-id name a saved turn of a conversation the caller can access,
and that turn is stored with the Continue mark. A hand-typed copy, a modified text, a missing or mismatching turn
id or a stored turn without the mark is classified as usual. Other detectors, the response phase and ghost chats
(which name no saved turn) are unaffected. See Prompt Injection.
Classifier scanning (prompt_injection)
If the gateway has a prompt_injection detector, the Llama Prompt Guard 2 classifier
also scans each tool result at the same boundary — a trained, multilingual model that catches
paraphrased and non-English injections the keyword tripwire cannot. It runs in addition to any
keyword scan; a result already withheld by the keyword scan is not re-classified. Applicability
follows the same target rule (request/both/absent). A classifier withhold counts into the same
triage row (class prompt_injection, category guardrail_policy — queued, not paged as an
incident).
Each result going back to the model is classified in overlapping windows over its whole
length (1,280-byte windows overlapping by 256 bytes, so an instruction split at a boundary
still sits whole inside one window), up to the same scan bound as the keyword scan (96 KiB;
about 200 KiB for a document fetched by the agentic fetch). The verdict for a result is its
highest window score. Bytes past the bound are unchecked and handled as described above. A
result stored in a conversation record is classified over its first ~4 KB only. Text sent to the classifier is cut on a character boundary (a multi-byte character is never split), invalid UTF-8 bytes are replaced with U+FFFD, leading whitespace is skipped, and whitespace-only text is not sent. The work is bounded so a hostile source cannot
amplify it into a denial of service: at most max_texts results per tool leg (default 64),
batched in small POSTs, under a per-leg wall-clock budget (tool_budget_ms, default 5000 ms). Each POST waits at most for what is left of the budget (never longer than the detector's timeout_ms), and no POST is started with less than 200 ms left; results not classified by then count as a budget outage (governed by fail_open).
Classifier configuration (system-global, DB). How the classifier is reached (transport), the
classifier endpoint and its basic-auth credential (direct transport only), and the two resource bounds
above are system-global configuration stored in the database (not per-gateway) — set once by a
platform admin via the classifier-config endpoint
below. On the hosted platform the classifier is reached through the Myra fleet (transport: "fleet"):
the gateway calls ${MYRA_BASE_URL}/prompt-guard-2/classify with the fleet credential, like the other
Myra fleet services, and the fleet spreads the calls over the classifier replicas. A database migration
switched the pre-configured row to the fleet; it never changes a configuration a platform admin has set
to another endpoint. If the configuration is still empty or cannot be decrypted (for example a
self-managed installation with its own master key), every gateway with a block-action prompt_injection detector
treats the classifier as unconfigured and fails closed (blocks, unless the detector is
fail_open). A flag-action detector passes the request through instead: observe-only never
enforces, on a detection or on an outage, and fail_open is inert for it — including an explicit
fail_open: false. The
credential is stored encrypted and is never returned by any read. A configuration change
propagates to all serving hosts within a short cache TTL. Only the per-detector
injection_threshold cutoff is per-gateway (in the gateway's guardrail config).
Action and fail-closed. A result whose p_injection >= injection_threshold under a
block-action detector is withheld behind the placeholder; a flag detector logs it and
passes it through. On a classifier outage — or when a result is left unscanned because a
bound was hit — a block-action detector that is not fail_open withholds the affected
results (fail-closed), so injected content never reaches the model unscanned; a flag-only or
fail_open detector passes them through — and that pass-through is recorded on the request
when its cause is an outage: an unconfigured classifier (guardrail_error.error_class
config), a failed classifier call (http_NNN / transport), or a spent tool_budget_ms
(budget_exhausted) write guardrail_error, guardrail_degraded and guardrail_verdict =
error, so the row counts as a guardrail gap and in the guardrail_unavailable alert — for a
flag-only detector too, exactly as the request phase records its outage. A result left
unscanned by the max_texts cap is a designed bound, not an outage, and is not recorded.
This detector defaults to fail_open: false.
Accepted / rejected classifier response. The classifier's answer is untrusted. Per submitted
text the gateway accepts only an object with label ∈ {"benign", "injection"} and
p_injection a finite number in [0, 1]; the numeric probability is authoritative for the
verdict (p_injection >= injection_threshold) and the label is never used to override it. A
non-2xx status, transport failure, non-JSON/scalar/array body, a results array whose length
does not match the submitted texts, a missing/non-string/out-of-enum label, or a
missing/null/non-number/NaN/out-of-[0,1] p_injection is rejected and treated as a
classifier outage (governed by fail_open). See
Prompt Injection → Classifier output validation.
Prompt-injection classifier config (system-global)
Platform-admin endpoints to configure the shared Prompt Guard 2 classifier. Platform-admin
only (permission PROMPT_INJECTION_CONFIG_MANAGE); a caller without it receives 403. Every
write is audited (hash-chained), recording the endpoint and the resulting configured flag — the
credential is never written to the audit log, returned by a read, or logged.
GET /admin/v1/system/prompt-injection-classifier
Returns the current config without the credential:
{ "endpoint": "https://…/classify", "transport": "direct", "configured": true, "reason": null, "tool_budget_ms": 5000, "max_texts": 64 }
transport says how the gateway reaches the classifier:
transport |
Meaning |
|---|---|
direct |
A direct HTTPS call to the stored endpoint with the stored basic-auth credential. |
fleet |
Through the Myra fleet: ${MYRA_BASE_URL}/prompt-guard-2/classify with the installation's fleet credential. The stored endpoint and credential are not used (they are kept only so a platform admin can switch back to direct). |
null |
The stored value is neither of the two (reason is invalid_transport). |
configured is true only when the stored config would resolve into a usable classifier: on direct a
present, decryptable credential and a valid https endpoint; on fleet a fleet base URL and a usable
fleet credential on this installation (a credential the fleet has rejected — for example a missed
rotation — counts as not usable). reason is null when it is, and otherwise says why not:
missing, credential_unreadable, invalid_endpoint, invalid_transport or fleet_unconfigured
(the table in
Enforcing prompt_injection needs a configured classifier).
If the fleet credential setting cannot be read right now, the read answers 503 (retry), never a
configured claim. An unset config returns
{ "endpoint": "", "transport": "direct", "configured": false, "reason": "missing", "tool_budget_ms": 5000, "max_texts": 64 }.
The same status on the guardrails reads. GET /admin/v1/tenants/{id} (for an organisation
admin who may edit the guardrail baseline) and GET /admin/v1/gateways/{id} (for a caller with
GATEWAYS_MANAGE) carry it read-only as pi_classifier: {"usable": <configured>, "reason": <reason>},
never with the endpoint or the credential. It is null when the status could not be read. The
gateway read also carries the organisation's guardrails_fail_closed (0 or 1) at the top level.
pi_classifier is ignored when a PATCH echoes it back.
PUT /admin/v1/system/prompt-injection-classifier
Body:
| Field | Type | Notes |
|---|---|---|
transport |
string, optional | "direct" or "fleet". Omitted ⇒ the stored transport is kept (direct when nothing is stored). Any other value, JSON null included, is rejected. |
endpoint |
string, required for direct |
The classifier URL. Must be https:// and must not embed userinfo (user:pass@host) — the credential must never ride the logged/stored URL. On fleet it is optional (validated when sent); omitted ⇒ the stored value is kept. With an explicit transport: "direct" it may be omitted when the stored endpoint and credential together are usable (see below). |
basic_auth |
string, required for direct |
The user:password basic-auth credential. Stored encrypted; never returned or logged. On fleet it is optional; omitted ⇒ the stored (encrypted) value is kept. Same exception as endpoint for an explicit transport: "direct". |
tool_budget_ms |
integer, optional | Per-tool-leg wall-clock budget. Clamped to [100, 60000]. Omitted ⇒ the existing value is preserved (default 5000 on a first write). |
max_texts |
integer, optional | Per-leg result cap. Clamped to [1, 1000]. Omitted ⇒ preserved (default 64). |
Rejected (400): a transport other than "direct" / "fleet"; with no transport while the stored
one is direct, a missing endpoint or basic_auth; with an explicit "direct", a missing endpoint or
basic_auth whose stored value is blank or unusable (the resulting row must have a valid endpoint and a
credential that decrypts); no transport while the stored one is malformed; an empty basic_auth, a
non-https scheme, a userinfo-bearing URL (whenever sent), or a non-numeric tool_budget_ms/max_texts.
A body without transport (for example an older script) therefore never switches the transport.
Switching back to direct while the stored endpoint and credential are still usable needs only
{"transport": "direct"}. After the stored credential was removed it needs transport: "direct", an
endpoint and the classifier host's basic-auth credential in the same request.
The change and its audit entry (system.prompt_injection_classifier.set, endpoint, transport, configured flag and bounds — never the
credential) are written in one transaction: either both are stored or neither is. If nothing could be written
(a transient fault, for example a lock wait) the write answers 503 { "error": "temporarily unavailable; retry later" }
and nothing changed — retry. A permanent fault, or one after which the outcome is unknown, answers
500 { "error": "internal error", "request_id": "…" } (the cause is logged, never returned). A write refused with nothing
written (503) does not invalidate the classifier cache; after a 500 whose outcome is unknown the cache is re-read. A failed read (GET) answers 503 (retry). On success (200) the change
takes effect on the next classification, propagating to all serving hosts within a short cache TTL.
The SPA shows the status read-only under Platform › Settings (for a caller with this permission);
changing it stays an API call. The card also shows how the classifier is reached (direct or through the
Myra fleet).
Per-role policy (role_policies)
A gateway can bind a stricter guardrail profile and/or a narrower model allowlist to
a specific user role within the single gateway, via an optional role_policies block on
the gateway configuration:
"role_policies": {
"member": { "guardrails": [ /* extra detector objects */ ], "models": [ "qwen-eu", "gpt-eu" ] },
"default": { "models": [ "qwen-eu" ] } // applies to any role without its own entry
}
The role is the server-derived authenticated role — a caller cannot assert its own role. The dimension is tighten-only: it can only make policy stricter than the gateway base, never looser, so the gateway base configuration remains a hard floor that a role override can never weaken or bypass.
guardrails— EXTRA detectors, unioned onto the gateway's base detectors for that role (a role can add strictness; it never removes a base detector, which always still runs). A role detector runs in the phase(s) itstargetnames:request(the default),response, orboth— response-phase role detectors are honored (aresponse/bothrole detector on a streamed request forces the answer to be internally buffered so the detector actually runs, exactly as a base response detector does). Role detectors run after the base set (they are not re-tier-sorted), so a role detector observes the text after any base masking — it cannot block on content a base PII detector has already scrubbed. A role detector'stargetreads the same way as a base detector's: an omitted,nullorfalsetargetresolves torequest— a null- or false-target role detector runs on the request phase (since October 2026 also forfalse, which before matched no phase on a role detector while the base reading ran it), so one stored shape resolves identically on both carriers. A role's PII masking detectors (custom_pii,pii_protector,presidiowithaction: "scrub") and itsregex/keyworddetectors withaction: "scrub"or"block"on the request phase also apply to tool results returned to the model, as the base ones do; and a role PII detector on either phase counts as the PII layer that turns on the user's personal PII keywords.models— an intersection mask: a member of that role may use only a model that is also in this list (and still within any gateway/plan allowlist — the gates compose, so a role can never grant a model the base disallows). An emptymodelslist denies every model for that role (a deliberate "no model here" configuration; note this is the opposite of an absentmodelskey, which imposes no mask). The mask is enforced on the final resolved model, at the guardrail stage — after routing, per-turn Auto model upgrades, and self-serve failover have run — so a system-initiated model swap cannot carry a role onto a model its mask excludes (the residency / data-sensitivity guarantee). A request whose final model is outside the role mask is blocked with theguardrail_role_modelclass. The mask governs the primary (user-chosen) model only — inner/system legs (an agenticfetch_urlsub-request, a tool-loop continuation, a web-search probe) run on a gateway-chosen system model and are not role-mask-gated. The mask is also re-asserted on the primary turn's upstream swaps — the retry-time alternate-model swap and the provider-fallback-chain swap — at the per-attempt dispatch point before any network call, so a fallback can never egress the user's turn to a model the role excludes; an all-denied chain returns therole_model_not_allowed(403) error code.
role_policies has no department key: to give one department stricter guardrails, use a strict
gateway that only that department may use (see
Departments → Stricter guardrails for one department).
Role matching. role_policies keys must be one of the system roles (admin,
tenant_admin, ki_manager, member, viewer, demouser, finance) or the literal
default. A role with no matching entry uses the default entry if present, otherwise the
gateway base — i.e. unknown/unlisted roles default to base (allow); enumerate every role
(or set default) if the intent is default-deny. A custom (non-system) RBAC role never
matches and is treated as a config typo: a role_policies block with an unknown role key — or a
malformed shape (a non-object block, or a non-object role entry) — is rejected 400 at every
gateway-config write boundary (create, PATCH, and guardrail-config import), never silently stored
to no-match at runtime.
Residency deployments — set a fail-closed
default. A request with no role (an anonymous / user-less token, or anauth_required=falsegateway) resolves to a nil role, which lands on thedefaultentry if present, otherwise the gateway base (allow). If the mask exists to enforce residency, a nil-role request must not float to the looser base — set a restrictivedefault(or make the gateway base itself the strict floor) so an unauthenticated or user-less request cannot obtain a broader model set than any named role.
Accepted / rejected shape. At write time a malformed block is rejected 400 (see above). At
request time, a stored value with a malformed shape (null, a scalar, a wrong type at any level)
is treated as no override → the gateway base applies — it can never weaken the base or error
a request. An
out-of-mask model is rejected (403); an in-mask model and an unmatched role pass through.
Agent invokes. A saved-agent / agent-as-tool invoke runs under the agent owner's role (the existing runs-as-owner model), so its turn is processed with the owner's role policy, not the calling user's.
Reading guardrail statistics
GET /admin/v1/gateways/<ID>/guardrail-stats
Returns a single aggregate object covering the last 24 hours of traffic for the gateway. The figures are gateway-wide totals, not a per-detector breakdown:
| Field | Type | Description |
|---|---|---|
blocked |
integer | Requests blocked by a guardrail, including those where a guardrail block withheld a tool result or an agentic fetch in the agent's tool loop without refusing the request (marker guardrail_withheld). |
scrubbed |
integer | Requests scrubbed (but not blocked or withheld). |
flagged |
integer | Requests where a detector fired without blocking, withholding or scrubbing. |
degraded |
integer | Requests this gateway did not fully protect — those that reached a provider without the protection they were configured to get. Same definition as guardrail_outcome=degraded on the Logs API. A boolean marker counts unless it is absent, null or false; a malformed value counts as set (fail closed). Omitted for a caller without the REQUEST_LOGS_VIEW permission, who also receives only the acted events below. |
avg_guardrail_ms |
integer | Average guardrail processing time, in milliseconds. |
read_source |
string | The store that answered: mysql (default), clickhouse or mysql_fallback (ClickHouse was requested but not trusted for this window, so MySQL answered). Additive. |
Required role: any user with access to the gateway's tenant.
Read source. The setting request_log_read_source_guardrails switches this strip (only the stats; the events list below always reads MySQL) to ClickHouse, behind the same coverage and anonymisation checks as the other areas. The figures are identical to the MySQL answer: the same single builder produces both, and degraded is still omitted without REQUEST_LOGS_VIEW. The count of requests is bound to the tenant that owns the gateway on both stores (a request-log row carrying another tenant id is not counted); a gateway without a tenant id is always answered by MySQL. MySQL also answers when a user erased (Art. 17) within about the last hour owns or drove a request counted in this strip; an erasure of a user with no request in it does not affect the source.
Gap rule (byte-exact). What counts as degraded compares the stored verdict and the failed detector name byte for byte: a verdict of error or indeterminate (exactly, lower case) and a non-empty detector name (an all-space name counts as present). ERROR or error is not a gap verdict. The same rule applies to guardrail_outcome=degraded and any on the Logs API and to the events list below.
The endpoint does not accept time-range query parameters; the window is fixed at the trailing 24 hours.
Listing recent guardrail events
GET /admin/v1/gateways/<ID>/guardrail-events
Returns recent guardrail activity, newest first — both directions of it:
- the guardrail acted: it blocked, scrubbed, or fired a detector; and
- the guardrail did not protect the request: the request proceeded despite a detector failing
open, a scrub that could not be committed, a body with no scannable text, unmasked PII egressing
under an active mandate, a
guardrail_verdictoferrororindeterminate, or ametacolumn too large to store in full. A request refused before dispatch is not this — nothing left — even when the refusal happened because the detector errored and its fail mode is closed. One blocked on the response phase, after the prompt already went to the provider, still is.
The second kind usually sets none of blocked, scrub_applied or detectors_fired, so it used to
have no row here at all — a fail-open bypass was invisible in the panel that exists to report guardrail
activity. It is now reported, and meta names which detector lapsed.
Required role: any user with access to the gateway's tenant, as before. A caller without the
REQUEST_LOGS_VIEW permission (held by admin, tenant_admin, and any custom role granted it)
receives the narrower acted-only event set this endpoint has always returned, with no meta —
the protection markers are per-request facts that the Logs API gates the same way, and
one of them records that personal data actually left the estate. Such a caller is never handed a
gap event it has no way to explain.
Each event contains:
| Field | Type | Description |
|---|---|---|
ts |
integer | Event time as Unix seconds. |
blocked |
integer | 1 if the request was blocked. |
scrub_applied |
integer | 1 if scrubbing was applied. |
detectors_fired |
array | Names of the detectors that fired. |
blocked_by |
string | Detector that caused the block, if any. |
block_reason |
string | Reason for the block, if any. A keyword, regex, custom_pii or jailbreak block reads redacted:<type>:<12 hex>; the matched value is never stored. Present only for a caller who holds the REQUEST_LOGS_VIEW permission (tenant admins and above); for any other role the key is omitted from every event. Rows written before the redaction may still hold a raw value, which is the reason for the permission gate. The route itself stays open to every role. The same rule applies to GET /gateways/{id}/guardrail-stats (the degraded counter is omitted without the permission) and to the guardrail panel of /stats. |
guardrail_latency_ms |
integer | Guardrail processing time, in milliseconds. |
guardrail_verdict |
string | Overall guardrail verdict. One of safe, unsafe, error, or indeterminate. safe and unsafe are content verdicts from Prompt Guard. error means a guardrail backend could not be reached or failed. indeterminate means a guardrail backend answered, and the answer could not be read as a verdict — for example a classifier replica returning repetition garbage behind HTTP 200. When several guardrails run in one request, the health verdicts (indeterminate, then error) take precedence over the content verdicts, so a degraded scan is never masked by a later clean one. |
provider |
string | Provider the request was routed to. |
model |
string | Model used. |
latency_ms |
integer | End-to-end request latency, in milliseconds. |
meta |
object | The guardrail protection markers for this request, including guardrail_gap, detector_types_fired (the type of each entry of detectors_fired) and — when a detector lapsed — guardrail_error.name. Same shape and same curation as on the Logs API. Absent for a caller without REQUEST_LOGS_VIEW. |
upstream_attempts |
integer | Provider dials attempted (0 = never dispatched). Present because the protection-gap verdict depends on whether the request reached a provider at all. |
There is no request or log identifier on these events.
Optional query parameter:
| Parameter | Type | Description |
|---|---|---|
limit |
integer | Maximum events to return. Default 50. A value above 200 is reduced to 200. Anything but a plain integer ≥ 1 (0, -1, 1e2, empty, repeated, more than 9 digits) is 400 {"code": "invalid_limit"}. |
The events list is always served from MySQL, whatever request_log_read_source_guardrails says. A database fault returns 503 (retry). It never returns an empty event list. The same applies to guardrail-stats, which never returns all-zero figures for a fault.
Reviewing guardrail hits
GET /admin/v1/guardrail-reviews
Lists the requests a content detector blocked, so a reviewer can follow up. Requires the GUARDRAIL_REVIEW permission ("Review guardrail hits", granted to admin and tenant_admin by default and delegable to a custom role). The permission is checked before the role: a tenant_admin whose GUARDRAIL_REVIEW was removed gets 403, as does an admin. A custom-role lookup fault returns 503 (retry).
Query parameter status (optional): pending, awaiting_second, approved, denied, expired, closed or all. Anything else, or a repeated or bare status, returns 400.
Scope. Rows are limited to your tenant. admin and tenant_admin see every guardrail hit of the tenant. Any other holder of GUARDRAIL_REVIEW sees only hits whose user belongs to the holder's own department. The department is read live from the user records on every call. A holder without a department sees an empty list. A hit with no recorded user (or whose user was deleted) is visible to admin and tenant_admin only.
Response. 200 {"items": [...]}, newest first, at most 500. Each item carries id, tenant_id, gateway_id, kind (guardrail_block), subject_ref (the trace reference of the request), summary (the blocking detector's name), status, requested_at and expires_at. No prompt text, matched entities or block reason is ever stored or returned. A session without a tenant returns 401.
What creates a hit:
- A top-level request or response that a content detector blocked. Blocks caused by a guardrail outage, an oversized document, a role model allow-list or a required-PII-protection rule create no hit.
- A streamed response block creates no hit (the response is already on its way to the client).
- Delegated child calls, scrub previews and token counts create none.
- A hit is open for 30 days. After that it is marked
expiredand stays listed (use?status=). Expired hits are deleted only by the periodic run-history cleanup, which follows the run-history retention setting. A hit is also deleted at once when its user is erased.
The hits are read-only. approve / deny on a hit returns 404, and the existing review inbox (GET /admin/v1/review-items) never lists them: ?kind=guardrail_block there returns 400.
Reading the circuit breaker state
GET /admin/v1/gateways/<ID>/circuit-breaker
Returns the circuit breaker state for each provider that currently has a live breaker entry on the gateway, keyed by provider name. Providers with no breaker state are omitted. A gateway that points the myra provider at its own endpoint (provider_base_urls.myra) gets one key per model, myra/<model>. The built-in Myra fleet's breakers are shared by all gateways and are not listed here (see Circuit breaker). Each entry has:
| Field | Type | Description |
|---|---|---|
state |
string | One of closed, open, or half_open. |
failures |
integer | Current consecutive failure count. |
opened_at |
integer | Unix seconds when the breaker opened. Present only while the breaker is open or half-open. |
Required role: any user with access to the gateway's tenant.
Masking preview (scrub-preview)
POST /v1/<tenant>/<gateway>/scrub-preview
A billing-free dry run of the request-phase PII masking. It never calls the model; it returns what the guardrails would mask so a user can review — and selectively adjust — the masking before sending. Authenticated with a short-lived gateway playground token (x-aig-token).
Accepted request shape. A JSON body { "text": string }. Two optional policy headers are
consumed, resolved exactly as a real send resolves them, so the preview reflects the same PII
mandate (a pii_mandatory project → values withheld, below): x-aig-policy-conv-id names the
conversation the draft will be sent into — its committed project decides, and a disagreeing
x-project-id is then not consulted (the web app sends both, so a stale project in the browser
cannot make the preview judge a different tier than the send); x-project-id scopes a draft for a
chat that has no conversation yet. Both are untrusted input, validated and fail-closed: a malformed
or repeated value is treated as a mandate in force (values withheld), never as absent. Rejected inputs (each fails closed, the
message is never scanned or sent):
| Condition | Response |
|---|---|
Method is not POST |
405 { "error": "method not allowed" } |
| Body is empty / unreadable | 400 { "error": "empty body" } |
Body is not JSON, or text is not a string |
400 { "error": "expected JSON body { text: string }" } |
text is the empty string |
200 with an empty, non-degraded result (nothing to scan) |
The request phase returned a body whose first message no longer carries a string content |
500 { "error": "guardrail post-processing failed", "code": "configuration_error" } — the same refusal the conversation summarisation route gives, and it takes precedence over any detector verdict (even a block): a corrupted pipeline is the truthful answer. The preview never answers 200 with a fabricated empty masked (that was a legacy behaviour: masked: "", degraded: false, "everything was masked"). This should not occur — a keyword/regex scrub that would change the document's shape is refused before it is committed (see when a scrub cannot be applied) — so if it fires, a masking layer rewrote the body outside that guard; the gateway error log names the gateway, the modal shows the error, and the failure counts in the health dashboard's scrub-preview failures. Report it rather than working around it. |
Response shape.
| Field | Type | Description |
|---|---|---|
masked |
string | The draft after masking — what the model would receive. Unmasked when nothing matched. |
detected |
array | One entry per detected entity type: { type, count, detector, action }. Empty when nothing was detected. |
spans |
array | Per reversible-redaction token { token, type, value }, so the UI can offer selective unmask. Only [MYRA-REDACT-*] tokens carry a span. Withheld under a PII mandate: when masking is mandatory for the caller — a pii_mandatory project (resolved from x-project-id), a tenant with pii_masking_enforced, an agent-area mandate, or a fail-closed indeterminate tier (the same pii_mandate_in_force condition that denies a send-time unmask) — spans is [] and no raw value appears anywhere in the response, while detected still reports what was masked. The client is never the authz boundary, so the preview does not hand a caller values it could never unmask. |
would_block |
boolean | True when a detector's action is block and the request would be refused. |
blocked_by |
string | Name of the blocking detector, present only when would_block is true. |
degraded |
boolean | True when a PII masking layer (presidio / pii_protector / custom_pii) could not run on a fail-open gateway (analyzer outage — 401/5xx/timeout/connection-refused, or a detector crash). In that case the draft was not fully scanned, so masked / detected are byte-identical to a genuine "no PII found" result and must not be presented as clean. Always present. A fail-closed PII outage instead returns would_block: true (the request is refused), not degraded. Only PII detector types set this — a non-PII detector (e.g. jailbreak) degrading does not. |
Why
degradedexists. On a fail-open gateway an unavailable analyzer makes the gateway proceed without masking rather than block. Without this field the preview would show zero detected entities — indistinguishable from "no personal data found" — and mislead the user into believing their draft was scanned and is clean. The masking-preview UI renders a distinct "PII detection incomplete" warning whendegradedis true. This surfaces the degraded state honestly; it does not change the fail-open policy (whether a gateway fails open is a tenant/operator decision).
Tenant guardrail baseline fields
The tenant guardrail baseline is written with PATCH /tenants/{id} (see the Tenants API) and requires tenant-settings permission.
| Field | Type | Notes |
|---|---|---|
guardrail_baseline |
array of detector objects, or null |
null or [] clears the baseline. A detector with enabled: false is stored and switched off (not applied), a non-boolean enabled is rejected, and so is a malformed prompt_injection injection_threshold or a malformed presidio / pii_protector score_threshold or entity_score_thresholds (400 invalid_guardrail_baseline, same rule as a gateway write). |
guardrails_fail_closed |
boolean on write; integer 0 or 1 on read |
When 1, a request is refused if a baseline detector cannot run. |
expected_version |
integer | The row_version you read. A stale value returns 409. |
Rejected input returns 400 with code invalid_guardrail_baseline or invalid_guardrails_fail_closed. A change that needs four-eyes approval returns 202 with status: "pending_approval" and no row_version.
On read, callers without tenant-editor rights do not receive guardrail_baseline at all (the key is absent). The console treats an absent key as "not permitted", a non-array value, or an array with a malformed entry (not an object, or a missing / empty type) or more than 64 entries, as "unreadable", and any guardrails_fail_closed value other than 0 or 1 as invalid, disabling the switch rather than showing it off.
The gateway GET attaches the folded list as config.guardrail_baseline. It is read-only: a gateway PATCH must not send it.
Guardrail configuration as code (export / import)
A gateway's guardrail configuration can be exported to, and imported from, a versioned JSON
file for GitOps / infrastructure-as-code workflows. Export is read-only; import applies a
file to a gateway and is audited + hash-chained like every admin mutation. Both endpoints
require the GATEWAYS_MANAGE permission (enforced server-side — the client is never the authz
boundary).
The file describes only the guardrail subset of the gateway configuration, never the whole
config. The exported/accepted keys are exactly: guardrails, detectors (legacy detector
array), role_policies, pii_thresholds, egress_guard, eu_region_routing,
provider_allowlist_enforced, provider_allowlist, transfer_safeguards_required. No other key is exported (so no BYOK key,
webhook secret, web_search.api_key, budget, or internal field can leak) and any other key in
an imported file is rejected.
File shape
{
"kind": "myra.gateway.guardrail-config",
"schema_version": 1,
"gateway_slug": "acme-prod",
"exported_at": 1691000000,
"config": {
"guardrails": [ /* detector objects */ ],
"role_policies": { "default": { "guardrails": [ /* ... */ ] } },
"eu_region_routing": true,
"provider_allowlist_enforced": true,
"provider_allowlist": ["anthropic", "myra"]
}
}
kind and schema_version are load-bearing (validated on import). gateway_slug and
exported_at are informational — import targets the gateway in the URL, so a file exported
from one gateway can be promoted to another (e.g. staging → prod). A detector's url field is
stripped on export and rejected on import (in every carrier — see below), so no
internal detector endpoint is ever written to the file.
GET /admin/v1/gateways/<ID>/guardrail-config/export
Returns the file above as a downloadable application/json attachment
(<slug>-guardrails.json). A gateway with no guardrail keys exports "config": {}.
POST /admin/v1/gateways/<ID>/guardrail-config/import
Body: the file above, optionally with "confirm": true. The import declaratively replaces
the guardrail subset — every guardrail key present in the file is set, every guardrail key
absent from the file is removed, and all non-guardrail keys (BYOK, webhooks, budgets, …)
are preserved untouched. (This differs from PATCH /admin/v1/gateways/<ID>, which merges the
keys you send; import is a full declarative replace of the guardrail subset.)
The write is made on the stored config at the moment of the write. The import locks the gateway row and replaces the guardrail subset on the config as it is stored then, not on the copy read when the request arrived. A change another administrator made in between to a key the import does not carry (a budget, the model list, …) is kept; the audit row's before/after are the guardrail subset actually replaced. Previously only trial-plan tenants were written this way — on every other plan an import could silently revert such a concurrent change.
Accepted / rejected input (each rejection fails closed — nothing is persisted):
| Condition | Response |
|---|---|
| Body not JSON / not an object | 400 |
kind ≠ myra.gateway.guardrail-config |
400 |
schema_version ≠ integer 1 |
400 |
config not a JSON object |
400 { "error": "config must be an object" } |
a config key outside the allowlist above |
400 { "error": "unknown guardrail-config key: …" } |
a detector carrying a url field — in guardrails, legacy detectors, or role_policies[*].guardrails |
400 |
a detector that is not an object, or lacks a non-empty string type |
400 |
| more than 64 detectors total across all carriers | 400 |
eu_region_routing, provider_allowlist_enforced or transfer_safeguards_required present, not null, and neither a JSON boolean nor the value this gateway already stores |
400 naming the field (the value is not echoed) |
provider_allowlist present, not null, and neither a valid list (an array of at most 64 non-empty, registered provider names) nor the value this gateway already stores. Also returned by dry-run |
400 { "error": "provider_allowlist: …" } |
the import would change provider_allowlist or provider_allowlist_enforced and the tenant is on the trial plan |
403 { "error": "…", "code": "trial_gateway_locked" } |
| the tenant record cannot be read (needed for the trial-plan check) | 503 (retry) |
the guardrail subset would change and confirm is not true |
409 with a diff (below) |
valid + confirm: true (or an unchanged/no-op re-apply) |
200 { "ok": true, "changed": <bool> } |
valid + confirm: true, a change, and the organization has config approval (four-eyes) on, caller not a platform admin |
202 { "status": "pending_approval", "approval_id": "…" } -- nothing is written until another administrator approves (Config approvals); an unchanged re-apply is never held |
| the gateway was deleted between the import's read and its write | 404 { "error": "gateway not found" } — nothing is written |
| the gateway write fails | 503 (retry) when nothing was written (for example the row lock could not be taken in time); otherwise 500 { "error": "internal error", "request_id": "…" } — the database's own text is never returned |
Residency flags in a file. The export writes eu_region_routing and provider_allowlist_enforced as their
effective boolean, whatever the gateway stores: a recognized-ON legacy value (1, "true") exports as true,
a recognized-OFF one as false, and an unrecognized one ("bogus") as false -- exactly how the gateway
reads it at config load -- so the file imports on any gateway. A flag that is absent or null is left as it is
(inherit the tenant default). On import, a value you send that is unchanged from what this gateway already
stores is accepted (a round trip of a legacy configuration keeps working); a changed non-boolean is refused.
The confirm gate is fail-closed: any change to the guardrail subset requires
"confirm": true. An unchanged re-import (the file equals the current guardrail config) is an
idempotent no-op and applies without confirm ("changed": false) — so a GitOps pipeline can
re-apply the same file safely. When a change needs confirmation the 409 body carries a diff:
{ "error": "guardrail configuration would change; re-send with \"confirm\": true to apply",
"diff": { "detectors_added": ["…"], "detectors_removed": ["…"],
"weakens_residency": false, "introduces_deny_all": false } }
weakens_residency is true when the import would lower the effective EU-residency or
provider-allowlist enforcement; introduces_deny_all is true when it would enforce a
provider allowlist with no usable providers (bricking all inference). These are advisory: the
residency floor is non-downgradable regardless — a tenant/deployment residency floor is
re-applied on every config load, so a stored value below the floor never takes effect (the same
guarantee PATCH has).
Four-eyes on PATCH /admin/v1/gateways/<ID>. When the organization has config approval on, a PATCH that really changes any guardrail key (guardrails, detectors, role_policies, pii_thresholds, egress_guard, eu_region_routing, provider_allowlist_enforced, provider_allowlist) or provider_base_urls answers 202 { "status": "pending_approval", "approval_id": "…" } for a non-platform administrator; the held change is the delta only and is applied, with the same validators, when another administrator approves. Other keys of the same body are held with it. A body that changes none of these keys is applied directly.
Detector carriers must be arrays. config.guardrails, config.detectors and every config.role_policies.<role>.guardrails must be a JSON array (or omitted; [] clears). null, false, true, an object, a string or a number is refused 400 by both the import and the dry-run, before the prompt-injection classifier check. A malformed value already stored on the gateway is grandfathered: a file exported from it imports and dry-runs unchanged, but a different non-array is refused.
Policy dry-run / diff
POST /admin/v1/gateways/<ID>/guardrail-config/dry-run
Evaluate a candidate guardrail policy against sample text and return the behavioral diff
versus the gateway's current policy — what would newly block / flag / scrub / pass — WITHOUT
applying anything. Requires GATEWAYS_MANAGE. It reuses the real detector pipeline read-only
(no upstream model call, no billing), so presidio / prompt_guard / pii_protector
detectors in the candidate do execute against the live analyzer.
Request. { "candidate": <guardrail-config object>, "source": "provided" | "last_n",
"samples": [ "text", … ] }. candidate is validated with the same rules as an import config
(key allowlist, detector url/shape, 64-detector cap). source selects the sample set (default
provided; any other value is rejected 400):
provided(default) — evaluate the caller-suppliedsamples: at least one non-empty string, at most 10 evaluated (blank entries skipped).last_n— evaluate the last-N real pre-mask prompts captured for THIS gateway (samplesignored). This requires the tenant's pre-mask-capture opt-in (default OFF — see below); until a tenant opts in, nothing is captured andlast_nreturns an empty summary with"note": "no_captured_traffic". A fault while reading the captured prompts gives the same answer. The read isGATEWAYS_MANAGE-gated to the owning gateway, and the response is verdict-only (the stored prompt text is never returned).
Pre-mask prompt store (last_n source). Stored request_log.prompt is already PII-masked,
so re-scanning it is blind to the very PII a candidate policy targets. To dry-run over real
traffic, a pii_protector gateway can — only when its tenant enables
pre_mask_capture_enabled (per-tenant DB config, default OFF) — persist the raw PRE-mask
user prompt on turns where PII was actually masked. This is a tightly-fenced raw-PII store:
per-(tenant, gateway) last-N (default 50, pre_mask_capture_cap), a short per-tenant TTL
(default 48h, pre_mask_capture_ttl_hours) reaped hourly, residency-tagged, wiped on tenant
erasure. Captured content is user-role prompt text only (system/assistant/tool-call args
excluded); it is never logged and never leaves the verdict-only dry-run of the owning gateway.
It is INCOMPLETE BY DESIGN — only pii_protector request-phase turns with masked user PII are
captured.
Response. Verdicts only — the sample text is never echoed back (nor any matched value / pattern / entity), so a sample carrying PII cannot leak through the diff:
{ "summary": { "newly_blocked": 1, "newly_passed": 0, "changed": 0, "unchanged": 1 },
"samples": [ { "index": 0, "source": "provided", "before": "pass", "after": "block" },
{ "index": 1, "source": "provided", "before": "pass", "after": "pass" } ],
"unrunnable_patterns": [] }
unrunnable_patterns (always an array, also on the no_captured_traffic answer) lists every
regex custom_patterns entry of the candidate that the engine cannot run, without the
write check's grandfathering: a broken pattern stored before that check is accepted by the
candidate validation (a save must stay possible) but is skipped at runtime, so its verdict reads
pass. Each entry is { "detector": <name or "">, "carrier": "guardrails" | "detectors" |
"role_policies:<role>", "index": <1-based position>, "reason": <why>, "message": <full sentence> };
message quotes the first 64 characters of the pattern — the caller's own candidate, never sample
text. A pattern listed here makes that detector's verdict meaningless; the Guardrail Builder's
sample test shows it as "could not run".
before / after are each one of block, scrub, flag, pass. A transition to block is
counted newly_blocked; block → anything looser is newly_passed; any other change is
changed. An empty samples array (or one with no non-empty string) is rejected 400.
Numbers in the scrub preview response are written exactly. If the response cannot be encoded, the endpoint answers 500 with { "error": "internal error", "code": "response_encode_failed" }; see Error codes.
Guardrail service replies
The Presidio analyzer / anonymizer, the PII Protector, Prompt Guard and Prompt Injection detectors
each ask a sidecar service for a verdict. The gateway reads those replies through one strict reader
and treats an untrustworthy reply as a detector failure (verdict error, routed through the
guardrail's fail mode), never as "nothing found".
A reply is refused when it is blank, is not the expected JSON shape (an array from the analyzer, an
object elsewhere; {} from /analyze is refused), contains NaN / Infinity, an out-of-range
number, a repeated object key, a raw NUL byte (an escaped \u0000 inside a string decodes and is accepted), or exceeds its size or structure budget. The budgets are
derived from the request (the analyzer reply scales with the number of input characters, the
anonymizer reply with the input size and the span count; classifier replies are capped at 1 MiB).
A reply cut off by the transport size cap is a failure, not an empty result. An integer score of 19
or more digits is accepted as the nearest double.
Effect by phase: on a request with fail_open: false the caller receives the guardrail block
response; with fail_open: true the request is served with the guardrail_degraded marker. When the
anonymizer reply is refused on a request that is known to contain PII, the request is blocked
(presidio_partial_scan_failed) whatever the fail mode says. A refused analyzer chunk reply is
retried within the run's time budget by the existing bounded chunk retry. A refused anonymizer reply
is not retried: it takes the fail mode at once. A refused reply is never cached. A refused classifier reply carries no usable usage, so it is counted as 0 tokens.
Operators see aig_guardrail_reply_refused_total{detector,service,reason} (reason is one of blank,
over_budget, invalid_token, out_of_range, malformed, nul, duplicate_key, wrong_shape),
one [guardrail_reply] refused a ... error line per minute per detector and service (never the reply
bytes), and a reply_refused_<reason> entry in the model-error triage.