Skip to content

NLP PII detector

The NLP PII detector is a Tier 2 (sidecar HTTP call, milliseconds) guardrail that uses a named entity recognition (NER) engine to detect and optionally anonymise personally identifiable information (PII) in request and response bodies. The detection engine runs as a locally hosted sidecar within Myra's certified infrastructure — data is never transmitted outside the Myra perimeter.

Screenshot: Presidio (NLP) guardrail editor in the Guardrail Builder NLP PII detector editor

When to use the NLP PII detector

Use the NLP PII detector when you need contextual, NLP-based detection of PII — including unstructured forms such as names, locations, and dates that regex cannot reliably match. For structured data formats with known patterns (card numbers, SSNs), the Regex guardrail (Tier 1) is faster and requires no sidecar call.

How it works

The guardrail extracts the message content from the request, sends each content field to a locally hosted Presidio sidecar, and applies the configured action to any span that meets or exceeds the score_threshold. The sidecar analyses each field using NER models and returns detected entity spans with confidence scores.

A PERSON span that is only a pronoun or a generic role noun — the Danish "du", German "Ich" or "Der Patient", English "I" or "my friend", which the model tags as PERSON — is not acted on by any action: a block detector does not refuse "Kan du hjælpe mig?", scrub leaves the word in place, flag does not record it. A span with any word that is not on the list is always acted on; a name that is spelled exactly like a listed word ("Du", "He") is a documented residual risk of the list. A pronoun used as a label or a greeting address at the very start of the text (You: hallo, You, are …, Ich: hallo, Hello You.) is not acted on either, unless a title, a name next to it or a use as a name elsewhere in the text says otherwise. A lowercase object pronoun (mir, mich, dir, me, them …) in front of a connector and a name ("von mir und Stefan") is not read as part of that name; the name itself is still acted on. The rules are those of the PERSON stop-list, shared with the PII Protector; it is always on, also under a PII mandate.

What is inspected

On the request phase the detector reads the content fields of the decoded request body, never the JSON request envelope. The following carry text and are inspected:

Carrier Notes
messages[].content Plain string content, on every role; a content array of plain strings is also read
messages[].content[] text blocks
messages[].content[] tool_result blocks String content and nested text blocks
messages[].content[] tool_use blocks Every string leaf of input, to a nesting depth of 64
system The native top-level system prompt — a string or a text-block array
prompt Legacy completions-style
input A plain string, an array of plain strings (batch embeddings), or the Responses-API array of message objects — including a function_call_output's output and a top-level input_text item
instructions

The request envelope — role, model, message and tool-call identifiers, block type discriminators, and every other structural value — is never inspected and can never be rewritten. A detector that rewrote a structural value produced a malformed request that the provider rejected with HTTP 400, and analysing the envelope caused the NER model to report PERSON for tokens such as model ids and tenant names on requests containing no personal data at all.

⚠️ Caution — not inspected. The following carry text but are deliberately excluded, so personal data in them is not detected and not masked:

  • thinking and redacted_thinking blocks. Extended-thinking blocks are replayed on later turns together with a cryptographic signature that covers the thinking text. Masking the text would invalidate that signature and the provider would reject the next turn of the conversation. redacted_thinking is opaque ciphertext.
  • Object keys inside tool-call arguments. The arguments of an earlier tool call (messages[].tool_calls[].function.arguments, the legacy function_call.arguments, a Responses function_call item) is a JSON document encoded inside a string. Its string values are inspected and masked in place (keys, numbers and whitespace stay as written, so the call remains valid JSON); arguments that are not valid JSON are inspected as plain text. A name used as an object key is not inspected.
  • messages[].name, user, metadata, tools[] definitions, and the string leaves of block types not listed above.

If the only text in a request rides one of the excluded carriers above (for example a tool call whose arguments hold personal data only as object keys), nothing is scanned and the request log records presidio_no_scannable_fields so such requests remain countable. On a tenant that mandates PII masking such a request is blocked (pii_unscannable_body) rather than forwarded unscanned; on any other gateway it passes. A request carrying no text at all — an image-only turn, a token count — is ordinary and is never blocked by this rule.

On the response phase the detector walks the same content fields per provider shape — the OpenAI-compatible choices[].message.content (a string or text blocks) and reasoning_content, the legacy completions choices[].text, the native Anthropic content[] text blocks, and an error envelope's message. Structural values (role, finish_reason, tool-call ids, the model name), the model-authored tool-call arguments (tool_calls[].function.arguments / tool_use.input, which the caller re-parses), and thinking signatures are never rewritten, so the provider's own answer keeps its shape. A response body that is not JSON is scanned as one document (there is no structure to corrupt). A response whose JSON shape is not recognised is passed unscanned rather than rewritten, and the request log records presidio_response_shape_unrecognized so it stays countable; a recognised but prose-free body (embeddings, a token count) passes silently. Because the answer is re-encoded from the decoded body when a mask is applied, numeric fields in a masked response may be reformatted in spelling (e.g. 1.0 → 1), but never in value; an unmasked response is delivered byte-for-byte. See Numbers in a masked response.

💡 Note: Because the masking is now applied to the decoded body, the prompt recorded in the request log for a scrubbing detector is the masked text. The original is not kept in the request log for this detector type. Exceptions: a saved chat conversation keeps the user's message as typed (the scrub applies to what is sent to the model, not to the stored chat), and the turn replay record, kept by default for model evaluation, stores the messages as the client sent them — before any guardrail — for the tenant's replay retention (30 days by default) unless the tenant is opted out.

⚠️ Caution: Running a presidio scrub detector and a PII Protector on the same gateway is still not recommended. A presidio scrub now preserves an already-applied PII Protector / custom-PII token — it never anonymises the token bytes, so the value can still be restored — which removes the most common way the two collided. But the combination remains fragile in the reverse order: once PII Protector has restored a value on egress, a presidio scrub running after it anonymises the real value irreversibly, with no token left to map back. Choose one masking detector per gateway.

Numbers in a masked response

When a scrub rewrites a response, the gateway keeps every number value-exact or refuses the response by name; it never rounds. Before the masked body is re-encoded, every number in it is checked. An integer a 64-bit double cannot hold exactly (9007199254740993) or beyond ±2^63 or a decimal a 64-bit double cannot hold exactly is refused as response_number_not_exact; a number-shaped token that is not valid JSON (NaN, 0x10) is refused as response_number_invalid. The refusal is a block, not an error, so fail_open does not turn it into delivering the unmasked answer. A response with no mask to apply is still delivered byte-for-byte, large numbers included. The wire shapes per client are listed under native tool-call numbers.

Block reasons a scrub can produce

A scrubbing detector fails closed rather than reporting a mask that did not happen. These appear as the block reason in the request log:

Reason Meaning
presidio_partial_scan_failed Personal data was detected, and the sidecar then failed (or the scan budget ran out) before every field could be masked. The request is refused rather than forwarded with data the detector had already identified. Retried first — a transient sidecar error does not produce this.
presidio_mask_not_applied The sidecar returned a field unchanged although it had reported maskable spans in it, so the mask did not land. Re-sent, already-masked history is recognised and does not trigger this.
presidio_reencode_failed The masked body could not be re-serialised, so the two representations the gateway forwards from would disagree.
response_number_not_exact Response phase: the answer holds a number that cannot be kept exactly (an integer a double cannot hold exactly or beyond ±2^63, or a decimal a double cannot hold), so the masked answer is refused instead of delivered rounded.
response_number_invalid Response phase: the answer holds a number-shaped token that is not valid JSON (NaN, 0x10).
pii_unscannable_body The tenant mandates masking and the request's only text rides an excluded carrier.

What the gateway hands the anonymizer is canonical, whatever the analyzer returned: exactly four fields per span — entity_type (a string; a null, empty, numeric or object label becomes PII, a type alias is honoured), integer start / end clamped inside the field (a fractional offset is widened to the enclosing integers, so a superset is masked, never less), and a finite score in [0, 1] — with duplicate spans collapsed (same label and range → one span, the higher score) and whitespace-only spans dropped. Measured against the sidecar (2026-09-13, replicated): a null, empty or alias-only label answers 422, an object label 500, a fractional offset 422, an infinite score cannot even be encoded (400), and a whitespace-only span is accepted but inserts a placeholder between two words (John<PERSON>Smith); an exact duplicate is accepted in 24 of 25 calls with one sporadic 502 (the transient class the retry already covers). An anonymizer failure on a field with detected personal data is a refusal, so each deterministic shape used to turn an untrusted analyzer response into a refused request. The analyzer boundary itself never yields a duplicate span on any path (single-chunk texts included).

The other reasons are request-phase. On the response phase the model has already generated, so those conditions report an error and are resolved by fail_open instead of withholding the answer; the two number reasons are the exception and always refuse.

When a scrub cannot be applied

With action: "scrub", masking is all-or-nothing across the whole request. If the sidecar fails on any field, nothing is masked and the detector reports an error, which is then resolved by fail_open; a partially masked request is never forwarded. If the masked body cannot be re-serialised, the request is blocked rather than forwarded, because the two representations the gateway forwards from would otherwise disagree.

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

⚠️ action: "scrub" here is DESTRUCTIVE, and it is not the same operation as the PII Protector's. Matched values are replaced with a static label such as <PERSON> or <EMAIL_ADDRESS>, and nothing ever puts them back — not in the model's answer, not in the stored conversation, and the pre-send masking preview cannot recover them (it can only restore values that were tokenised). The model therefore answers about <PERSON>, and that answer is kept. If the answer needs to reference the real values, use the PII Protector guardrail, which tokenises reversibly and restores on the response phase. Both controls are labelled "scrub"; the Guardrail Builder marks this one destructive in its execution plan and says so on the card.


Configuration reference

Field Type Default Description
type string — Must be "presidio"
name string — Human-readable label for this guardrail instance
action string "scrub" What to do when PII is detected: block, scrub, or flag
target string "request" Which phase to inspect: request, response, or both
entities array absent Entity types to detect. Leave the field out to detect all supported entity types. A write that sends an empty array [], null, a non-array, or an array containing a non-string or blank element is rejected with 400, naming the detector: an empty list is not an "everything off" setting, and null or a non-array gets a different error message than an empty list ([] or {}). 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). On a detector that keeps the 0.6 floor (any language but explicit English) with action: "scrub", PERSON and LOCATION are analysed in addition to this list — and on any request under a PII mandate they are analysed whatever language says (a mandate applies the floor at the enforcement layer, so "masking enforced" covers addresses and names even on an English-calibrated detector; such a request records the pii_floor_forced_by_mandate marker so the extra masking is explainable) — see German names and addresses. With action: "block" or "flag" the list binds exactly: only the types you tick are analysed, so unticking PERSON does stop a blocking detector acting on names — except on a request under a PII mandate, where the floor still applies because the gateway is certified as satisfying that mandate. A request is under a mandate when its project is on the pii_mandatory tier, or its tenant has masking enforced, or the project's tier cannot be resolved at all — an unknown tier fails closed. A local-only gateway (every configured provider first-party) exempts the model leg of an enforcing tenant's requests from that mandate — not the model-generated web-search query, which is masked by the pii_protector detector, never by this one
score_threshold number 0.7 Minimum confidence score for a detection to count (0.0–1.0) — see the note below for refused values
entity_score_thresholds object absent Optional per-entity confidence overrides — a map of entity type to its own threshold (for example { "PERSON": 0.85, "EMAIL_ADDRESS": 0.5 }). An entity listed here uses its own value; any entity not listed falls back to score_threshold. Each value must be a confidence in 0.0–1.0 (an out-of-range or non-numeric value is rejected, exactly as for score_threshold). Omit the field for no overrides (an empty [] or {} also means none); null is refused with 400. Lowering the analyzer floor here also lowers the threshold sent to the sidecar so the entity can actually be returned.
language string | null absent The NLP calibration for this detector, and the language sent to the analyzer. It decides the PERSON / LOCATION confidence floor: every value ⇒ 0.6, except a well-formed explicit English locale ("en", "en-GB", "en_US") ⇒ the English 0.9 (since this release; a malformed value such as "en-" keeps 0.6). See German names and addresses. Exposed in the Guardrail Builder as Language calibration on this card. The "" / non-string readings in this row describe what the runtime does with a value already stored; a write that introduces one is refused — see the accepted-shape note below.
timeout_ms integer 15000 Read timeout for the anonymizer sidecar call in milliseconds. Minimum 1000 ms, and a whole number. A lower value cannot complete a real anonymize call, so the detector becomes a guaranteed timeout and, on a fail_open detector, the request is forwarded unchecked. Values outside [1000, 120000], non-numeric values and an explicit null are rejected with 400; a value already stored on a detector is carried through unchanged. The runtime also clamps to [1000, 120000]. Connect timeout is fixed at 500 ms; send timeout at 2000 ms. The analyzer (detection) call does not use this value — large inputs are chunked and each chunk carries a budget-clamped read timeout instead (see Large-document handling).
fail_open boolean true When true, sidecar errors allow the request to pass through; when false, they block it

💡 Note: score_threshold and every entity_score_thresholds value are confidences between 0.0 and 1.0. A write (create, update, guardrail-config import and dry-run, and the tenant guardrail baseline) is refused with 400, naming the detector and the field, unless score_threshold is a finite number in 0.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 any entity_score_thresholds that is not an object of entity type to the same kind of number. NaN, Infinity and a repeated key are refused body-wide. A valid value is kept exactly and sent to the analyzer as written (for example 0.6499996 stays 0.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 {} for entity_score_thresholds means 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 (the 0.7 default, or the built-in per-entity table), never clamped to 1.0. A too-high threshold (for example 5, a typo for 0.5) would otherwise match no entity and let personal data reach the model unmasked. The Guardrail Builder blocks out-of-range input and warns when the threshold is set above 0.85.

⚠️ Accepted / rejected shape — language. A write that introduces or changes language to anything other than a usable locale string — null, a number, a boolean, an object, whitespace only, or a string carrying a control character — is rejected with 400, naming the detector; a value already stored is carried through unchanged so an existing configuration stays saveable. At runtime any non-string value — and any string carrying a control character, which is unusable rather than merely unrecognised — is treated exactly as an absent one and resolves to "auto", which is calibrated as German, so a malformed value masks more, never less. (A real non-English locale such as "fr" is a deliberate choice: it keeps the 0.6 score floor and is passed to the analyzer verbatim. Only an explicit English locale such as "en" raises the floor to 0.9, and even then not when a PII mandate applies or the scanned content itself is non-English.) language and score_threshold / entity_score_thresholds have write rules (see the note above); entities has a write rule too: leave it out for all entity types, or send a non-empty list of non-blank strings. Note this detector type does not send allow_list / allow_list_match at all — that is the PII Protector's. The Guardrail Builder no longer offers an Allow list control on this card, a write that introduces allow_list on a presidio detector is rejected with 400 (on create, on update, and on guardrail-config import), and a stored value is dropped the next time the gateway's guardrails are saved from the builder. A value already stored is grandfathered — carried through unchanged — so an existing configuration never becomes unsaveable, and it is stripped from an exported guardrail-config file so the file stays importable onto another gateway. To exempt specific values from masking, use a PII Protector detector, which sends the allow list to the analyzer and honours it.

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


Actions

Action Behaviour
block Request is denied if any entity is detected above the confidence threshold — except a PERSON span that is only a pronoun or role noun (see How it works). The caller receives a synthetic assistant message.
scrub Detected spans are replaced with <ENTITY_TYPE> placeholders (e.g. <EMAIL_ADDRESS>). The pipeline continues with the redacted body.
flag Entity detections are recorded in the request log (a pronoun or role-noun PERSON span is not). The pipeline continues without modifying the body.

💡 Note: The entity offsets recorded in the request log are field-local — they index the content field the entity was found in, not the raw request or response body. Rows written before this change indexed the raw body.

💡 Note: With action: "block" the detector stops at the first content field that produces a detection (a pronoun or role-noun PERSON span does not count), so the recorded entity list names what was found in that field rather than everything in the request. In the web app the block notice names the kind of data when every detected entity belongs to one data category (credit card, bank account, ID number, tax ID or health insurance number); a mix of categories keeps the general notice.


Supported entity types

The Guardrail Builder offers the entity types below; a custom entity type name can be added in the Entity types list. FP rates come from the gateway's false-positive benchmark at score_threshold: 0.7 (OR-Bench-hard, XSTest, a Dolly sample and a hand-written business set).

Entity type Description FP risk at 0.7
EMAIL_ADDRESS Email addresses Low
PHONE_NUMBER Phone numbers Low
US_SSN US Social Security numbers Low
CREDIT_CARD Credit card numbers (Luhn-validated) Low
US_BANK_NUMBER US bank account numbers Low FP, but not detected at 0.7 (highest score 0.05) — see below
IBAN_CODE IBAN bank account codes Low
US_PASSPORT US passport numbers (regex, US format only) Low FP, but not detected at 0.7 (highest score 0.1) — use PASSPORT
PASSPORT Passport numbers in any format — detected via NER (multilingual) Low
US_DRIVER_LICENSE US driver's licence numbers Low FP, but not detected at 0.7 (highest score 0.3) — see below
US_ITIN Individual Taxpayer Identification Numbers Low FP, but not detected at 0.7 (highest score 0.5) — see below
CRYPTO Cryptocurrency wallet addresses Low
IP_ADDRESS IPv4 and IPv6 addresses Low FP, but not detected at 0.7 (highest score 0.6) — see below
MEDICAL_LICENSE US DEA registration numbers (check digit validated) — not general medical licence numbers Low
URL Web URLs Low FP, but not detected at 0.7 (highest score 0.6) — see below
ORG Company and organisation names — detected via NER (multilingual) Medium — threshold auto-raised to 0.85
PERSON Full or partial person names High — ~20% FP at the analyzer, of which pronouns and role nouns ("I", "du", "Der Patient") are not acted on (see How it works); threshold 0.6 by default, 0.9 for an explicit English language — on English text; a masking English detector keeps 0.6 on German, Nordic, French or Dutch text. A request that ran at 0.9 for that reason records pii_floor_off_by_language; one that ran at 0.6 because of a PII mandate records pii_floor_forced_by_mandate.
LOCATION Location names High — ~18% FP; threshold 0.6 by default, 0.9 for an explicit English language — on English text; a masking English detector keeps 0.6 on German, Nordic, French or Dutch text. Same two markers as PERSON.
DATE_TIME Dates and times High — ~7–14% FP; threshold auto-raised to 0.9

Types the analyzer cannot deliver at the default 0.7. The FP column is a false-positive rate; it says nothing about whether a type is found. The analyzer never scores these six types above the value shown, so at score_threshold: 0.7 (and no override) they are never flagged, blocked or masked. The Guardrail Builder marks each such card with a Not detected at 0.7 badge (it follows the effective threshold: a per-type override first, else score_threshold, else 0.7) and shows one hint per class:

  • Real matches that score low — IP_ADDRESS (0.6), URL (0.6), US_ITIN (0.5). Set a per-type threshold with entity_score_thresholds, for example { "IP_ADDRESS": 0.6, "URL": 0.6, "US_ITIN": 0.5 }; more URLs and IP addresses are then flagged or masked, with the false positives that implies. Lowering the global score_threshold is not the remedy: it widens every type's band.
  • Not reliably detectable — US_DRIVER_LICENSE (0.3), US_BANK_NUMBER (0.05), US_PASSPORT (0.1). The pattern also matches order numbers or any digit run, so lowering the threshold mostly adds false positives. US passport numbers are detected under PASSPORT.

The maximum scores are measured against the analyzer sidecar and pinned by an end-to-end test, so a change in the analyzer shows up as a failing test rather than a silent gap.

Field-name nouns the NER model mislabels — "email" or "gmail" as an email address, "phone" as a phone number, "passport number" as a passport — are not reported or masked: a structured-type span whose whole text is on a closed list of such nouns is dropped first. Anything not on the list stays masked. See Field-name nouns tagged as structured PII.

💡 Note: For action: scrub, restrict entities to the 14 low-FP types and omit ORG, PERSON, LOCATION, and DATE_TIME. (For action: block or flag the same list is a good starting point and now binds exactly — PERSON and LOCATION are no longer added behind it, so a blocking detector will not refuse a request on a name. On a request under a PII mandate — a pii_mandatory project, a masking-enforced tenant (on the model leg, unless the gateway is local-only), or a project whose tier cannot be resolved — the floor still applies, so such a detector will refuse a name there — though not a pronoun or role noun the model tags as PERSON, see How it works; tick PERSON if you want that behaviour everywhere.) This set produces 0% false positives across benchmarks; that is a false-positive figure, and six of the 14 types are not detected at the default 0.7 (see above). The gateway automatically raises score_threshold to 0.85 for ORG and to 0.9 for DATE_TIME when they are included. PERSON and LOCATION use a 0.6 floor by default; the 0.9 threshold applies to them only when language is configured explicitly as English ("en", "en-GB", …).


fail_open behaviour

fail_open Sidecar unavailable
true (default) Request passes through as if no PII was found
false Request is blocked

⚠️ Caution: Set fail_open: false when PII detection is a hard compliance requirement. With fail_open: true, a sidecar outage allows all traffic through uninspected.

Tool results (action: "scrub"). A scrub detector also anonymises tool results before they reach the model. At that seam it does not read fail_open: on an analyzer or anonymizer outage the result is forwarded unmasked (logged, and recorded on the request as guardrail_degraded / pii_scan_degraded / guardrail_error) — unless a PII mandate is in force (a pii_mandatory project, or a tenant with masking enforced), where the result is withheld behind the [tool result withheld: PII scan unavailable] placeholder and the request records pii_mandate_masker_unavailable, even when a pii_protector detector follows it. A result bound for a wholly-local model leg is not a mandate case. A long web page arrives in windows of about 6000 bytes; each window is analysed together with about 256 bytes of the surrounding page text, and only the window is anonymised, so an entity cut by the window's start or end is recognised and its visible part anonymised rather than passed on as a fragment. Because no later scan sees that context, an analyzer or anonymizer outage during this window pass withholds the window unless the detector is explicitly fail_open: true (and no PII mandate is in force) — the pass-through default described above does not apply to it, except on a wholly-local model leg. The same holds at every other place the gateway cuts tool text before it is scanned — the 80 KB tool-result cap, document size limits, knowledge pages and program output (see PII Protector — Gateway cuts): the entity crossing the cut is analysed with up to 256 bytes of the dropped text, and an outage during that pass withholds the result unless the detector is explicitly fail_open: true outside a mandate (for program output only the cut stream is withheld; the other stream and the program's files are still delivered).

Workflow trigger content (action: "scrub"). An email body, an email attachment or a form upload is anonymised before a workflow stores it. There the open-by-default rule does not apply: an analyzer or anonymizer outage always withholds the content — see Workflow trigger content.

agentic_fetch parts (action: "block"). A block detector in the inner leg's request phase also pre-checks each paged part with the surrounding page text: an entity that crosses a window edge (and so would reach the inner request phase only as an unrecognisable fragment) fails the part exactly as an inner-request block does. Same outage rule as the window pass above (withheld unless explicitly fail_open: true outside a PII mandate; on a first-party local inner model, withheld only when explicitly fail_open: false); an entity the engine reports with an offset that cannot be placed withholds the part.


Large-document handling

The NLP detector's latency scales with input length, so a large document (for example a multi-hundred-page case file pasted inline into the prompt) cannot be analysed in a single sidecar call without exceeding its read timeout. To keep a legitimate large document from being fail-closed-rejected, the gateway analyses it in pieces:

  • Chunking. Each inspected field is split into ~16 KB chunks. Chunks are analysed independently and their entity offsets are merged back with global positions, with a small overlap window so an entity straddling a chunk boundary is still detected.
  • Per-chunk retry under one budget. A transient sidecar error on a chunk is retried; the whole scan is bounded by a single wall-clock budget (default 90 s). If the budget is exhausted the request fails per the fail_open setting — for very large documents that exceed the budget, ingest the document via the knowledge/RAG upload path instead of pasting it inline.
  • Ill-formed UTF-8 is normalized first. Input containing stray non-UTF-8 bytes (common in text copied out of PDFs or OCR output) is normalized to valid UTF-8 — each ill-formed byte becomes the Unicode replacement character U+FFFD — before chunking. This lets a large document with a few bad bytes be chunked and scanned rather than diverted to a single non-chunked call that would time out, and it keeps detection offsets aligned so redactions land on the right characters. The normalization is internal to PII analysis: a field is only rewritten in the forwarded request when PII is actually redacted in it; a field with no detected PII is forwarded with its original bytes unchanged.

Analyze-result cache (tenant-scoped)

A multi-turn conversation re-sends its whole history every turn, so the same document text would otherwise be analysed once per turn. The gateway memoizes each analyzer result by a collision-resistant hash of the exact fields sent to the sidecar (text, language, entities, score threshold, allow-list) for one hour, so an unchanged document is analysed once and the repeat is served from cache. The cached value is the detected spans only — never the original PII value, which is read from the live text at redaction time.

The request to the sidecar, the cache key and the stored spans all carry numbers exactly: a cached score is the one the analyzer returned, a first analysis and a later cache hit of the same text decide the same way, and the anonymizer receives the scores unrounded. A payload that cannot be encoded exactly (a non-finite number) is not sent and is not retried; the detector fails by name before any call to the sidecar.

The cache is per tenant. The hash includes the requesting tenant, so a cached entry is only ever reused for the tenant that produced it — one tenant's document, template or variable can never produce a cache hit for another tenant. A tenant's own gateways and conversations still share (the multi-turn optimisation above is unchanged). This deliberately gives up cross-tenant reuse of an identical (text, config) (and the small Presidio load it saved): a shared entry let a hit/miss timing difference confirm that another tenant had processed a specific document, which a tenant-isolated, EU-sovereign deployment must not expose.


Example configurations

Block any request containing detected PII

{
  "type": "presidio",
  "name": "block-pii",
  "action": "block",
  "target": "request",
  "fail_open": false
}

Scrub specific financial entity types from both request and response

{
  "type": "presidio",
  "name": "scrub-financial",
  "action": "scrub",
  "target": "both",
  "entities": ["CREDIT_CARD", "IBAN_CODE", "US_BANK_NUMBER"],
  "score_threshold": 0.85
}

Flag PII in responses for audit purposes only

{
  "type": "presidio",
  "name": "flag-pii-responses",
  "action": "flag",
  "target": "response"
}

Using the NLP PII detector after a regex pre-filter

Running a regex guardrail first (Tier 1) reduces the volume of content reaching the Presidio sidecar (Tier 2). The example below blocks card and bank-account data (card number, CVV, IBAN) in-process, then sends everything else to the NLP PII detector for broader PII detection.

[
  {
    "type": "regex",
    "name": "block-card-data",
    "action": "block",
    "target": "request",
    "patterns": ["cc", "cvv", "iban"]
  },
  {
    "type": "presidio",
    "name": "scrub-remaining-pii",
    "action": "scrub",
    "target": "request",
    "entities": ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER", "US_SSN"]
  }
]

Streaming

When target is "response" or "both", the gateway buffers a streamed response, scans it, and then sends it on to the client. Response-phase block, scrub and flag therefore apply to streamed responses as well. Only the PII Protector and the Custom PII blacklist restore values inline while the response streams.


Configuring the NLP PII detector

Screenshot: NLP PII detector card in the Guardrail Builder NLP PII detector card — expanded view

Proceed as follows to configure the NLP PII detector in the Guardrail Builder:

  1. Open the gateway page (Organisation › AI setup › Gateways) and its Guardrails & residency tab with the Guardrails card.
  2. Click on the Presidio (NLP) button.
    • A collapsed NLP PII detector card appears at the bottom of the list.
  3. Click on the card to expand it.
  4. Enter a name in the Name text field.
  5. Select the action from the Action drop-down list: block, scrub, or flag.
  6. Select the target from the Target drop-down list: request, response, or both.
    • A new card starts with the action block, the target request, the 14 low-FP entity types, a score threshold of 0.7 and fail open on.
    • With scrub, the card shows a warning that the replacement is irreversible.
  7. If required, adjust the Score threshold field.
    • Above 0.85, the card warns that lower-confidence PII may reach the model unmasked.
  8. If required, change the entity types in the Entity types list:
    • Click on the Focused PII (low FP) button to select the 14 low-FP types.
    • Click on the All entities (~10-15% FP) button to analyse every supported type. The card then shows every listed type ticked; the analyzer also covers supported types that are not listed in the grid.
    • Clearing a tick while All entities is active asks for confirmation first, because it turns All entities into a fixed list of the types still ticked (the key is then stored). Adding a custom type while All entities is active asks the same way and then stores every listed type plus that one as a fixed list; typing a type that is already ticked changes nothing. A hand-ticked list that happens to contain every listed type is a fixed list too, not All entities.
    • Activate or clear single entity checkboxes, or enter a custom entity type (for example IN_PAN) and add it.
    • The last selected entity type cannot be cleared: the card keeps it selected and shows a notice. To analyse every type, click All entities instead.
  9. If required, select the calibration from the Language calibration drop-down list (see the language field). Switching to English asks for confirmation.
  10. Clear the Fail open (allow requests if Presidio is unreachable) checkbox if the sidecar must be a hard dependency.
  11. Click on the Save Guardrails button.

ℹ️ There is deliberately no Allow list on this card. This detector type never sends an allow list to the analyzer, so every value entered there was silently ignored — and on an action: "block" detector the request was still refused on a value the operator had explicitly exempted. Use a PII Protector detector to exempt values from masking.

-> The NLP PII detector is saved and appears in the execution plan.


JSON number fields are not inspected

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

Pipeline position

The NLP PII detector is Tier 2 — it makes an HTTP call to a sidecar service. All Tier 1 guardrails (regex, keyword) run before any Tier 2 guardrail. Within Tier 2, guardrails run in the order they appear in the guardrails array.


See also