Masking or blocking PII in NeMo Guardrails: which one fits your assistant
When an LLM assistant receives personal data in a prompt, a response or retrieved content, you have two main options in NeMo Guardrails: reject the request or mask the personal data and continue. Blocking fits when the assistant should not process personal data at all, while masking fits when the conversation has a legitimate purpose and the model only needs the surrounding context. The right choice depends on the user journey, what the model is allowed to see, and what your logs must hold.
The modes are easiest to think of as three outcomes a rail can produce. Block stops the message and returns a refusal or handoff, so the model never receives the content. Mask replaces detected values with a placeholder such as a label or a redacted token, then passes the sanitized text on. Anonymize is the masking variant in which values are replaced with consistent substitutes so the conversation still reads naturally. Regulated intake forms and identity-sensitive flows usually favor block, because the assistant should not hold the data at all. Support flows often favor mask, since an agent must still answer the question about an order without seeing the full card or account number. Internal knowledge bots frequently need masking on retrieved content, so that employees can search documents without the model repeating personal details back. Confirm these choices with your privacy and compliance owners before you configure them.
The detectors that find personal data are covered on the sibling pages for Presidio, GLiNER-PII, Private AI and regex rails, so this section focuses on the decision. Before you build, write down, for each assistant, which mode applies to input, output and retrieval separately, because a single assistant often needs block on one path and mask on another. Then check the traces and logs, since a masked prompt may still be recorded in full if content capture is enabled, and confirm that setting in the NeMo Guardrails documentation at NeMo Guardrails documentation before you rely on it.
How each mode changes the user experience, the model input and the logs
In block mode, a rail that detects personal data stops the request before it reaches the model and returns a refusal message instead. The model receives no prompt for that turn, so the decision happens entirely in the guardrail layer. The user sees a fixed response, and the application has to treat that response as a normal outcome, not as a model failure.
- User view: the user receives the refusal text defined in the configuration, and the conversation does not continue with that message.
- Model input: nothing from the blocked message is sent to the model for that turn. Confirm whether the same holds for retrieval and output rails in your version.
- Response shape: the reply is a fixed refusal, so client code and downstream systems should handle that text as an expected result.
- Logs and traces: the blocked input may still be recorded unless content capture is disabled. Confirm this in your own configuration.
Check whether the refusal reveals which entity type triggered it, and whether a user can retry with the data removed.
In mask mode, detected spans are replaced with placeholders and the request continues to the model. The conversation keeps going, which suits assistants where a refusal would stop a legitimate task. The model answers the masked version of the prompt, so the quality of the answer depends on how much context the placeholders preserve.
- User view: the conversation continues. The user may still see their original text in the interface unless the application redacts its own display.
- Model input: the model receives the anonymized text, with detected spans replaced by entity placeholders. Original values are not passed to the model under this rail.
- Response shape: the model may repeat a placeholder in its answer, so users may see placeholder text in the reply. Output rails determine whether the model's own output is masked too.
- Logs and traces: confirm whether logs capture the input before or after masking, since that decides whether original values appear in the record.
Test with representative prompts, because placeholders can remove context the task needs. Confirm the placeholder format your detector produces.
Reversible masking would store a mapping from each placeholder to its original value, so the application can restore the values in the final answer. The NeMo Guardrails documentation supplied for this page does not establish that the toolkit provides this behavior, so treat it as unverified until you confirm it in the NeMo Guardrails documentation for your version. If it is needed, plan it as custom application work.
- Support status: confirm whether your version offers a built-in restore step. Do not assume it exists.
- Custom build: if the mapping is built in application code or a custom action, it needs its own storage, access control and expiry.
- Model input: the model still sees placeholders only, so original values are not sent to the model.
- Logs and traces: the mapping is itself personal data and must be protected and retained under your policy.
Ask whether restoring values in the output is needed at all, because restoration reintroduces the personal data the masking step removed.
Logging behavior matters in every mode because a rail can see the original text even when the model does not. The record may therefore contain personal data that the model never received. Where the detector sits relative to the logging and tracing steps decides what each sink stores, so confirm the order in your configuration and version.
- Blocked content: the rejected input may be retained in logs, traces or telemetry depending on your settings.
- Masked content: logs may show masked or original text, depending on whether capture happens before or after the rail runs.
- Content capture: confirm the default and the setting that controls capture of prompts and responses in your version.
- Telemetry: usage telemetry is a separate setting. Confirm how to disable it and document the decision.
Run a test prompt that contains a clearly fake identifier, then search every log, trace and telemetry destination for that value in each mode.
Configuration options and when each one fits
This table compares the main choices for handling personal data in NeMo Guardrails: block or mask on detection, separate settings per rail, and detector choice. Read each row for what the user sees, what the model receives, and what to confirm in your version. The main takeaway is that the action and the detector both change the outcome, so set them together and test them on your own data.
| Option | What happens to the request | What the model sees | Best fit and what to confirm |
|---|---|---|---|
| Block on input detection | The turn is rejected before the model call and the user gets a refusal message. | Nothing from the blocked turn. The model is never called for that prompt. | Best when any personal data in a prompt is unacceptable. Confirm the refusal text and whether the blocked turn stays in conversation history. |
| Mask on input detection | Detected spans are replaced with placeholders and the request continues. | Placeholders in place of the original values. | Best when the task still works without the value. Confirm the placeholder format and which text later rails and logs receive. |
| Block on output detection | The model response is suppressed if personal data appears in it. | The model has already generated the text, so generation cost and exposure still occur. | Best when the model could echo data from context or training. Confirm whether the suppressed generation is written to logs or traces. |
| Mask on output detection | The response is returned with detected spans replaced by placeholders. | The full generated text, before masking takes effect for the user. | Best when a useful answer exists without the identifier. Confirm the placeholder and whether unmasked output reaches traces. |
| Retrieval rail (block or mask) | Personal data in retrieved chunks is masked or dropped before prompt assembly. | Masked chunks, or no chunk where blocking removes it. | Best for knowledge bases holding personal records. Confirm that retrieval access control still limits which documents are fetched. |
| Separate settings per rail | Input, output and retrieval rails each take their own action. | Depends on each rail. For example, blocked input and masked output. | Best when inbound and outbound risks differ. Confirm each rail in config.yml and test the combined behavior end to end. |
| Strict blocking on broad detectors | Any match on a broad entity such as names blocks the request. | Nothing for false-positive matches, which hurt legitimate users. | Best only for high-risk entities. Expect false positives on names and identifiers. Check thresholds on the Presidio page. |
| Detector choice | Presidio, GLiNER-PII, Private AI and regex find different spans, so the same action gives different results. | Different placeholders depending on which spans were found. | Match the detector to your entity set and data location. Confirm entity lists and score thresholds on the sibling detector pages. |
Where block and mask decisions happen in a request
The request starts at the user prompt and passes through input rails, where a PII detector such as Presidio, GLiNER-PII, Private AI or a regex rail finds personal data. The detection result branches: a block outcome returns a refusal without calling the model, while a mask outcome rewrites the text and lets the model call continue. Retrieved RAG chunks pass through retrieval rails before they reach the prompt, and output rails check the response before it is returned. Check where the logs and traces store content, because the original text can persist there even when the model never sees it.
Block and mask branches in the input rail, with retrieval and output checks and where content is logged.
What the model, logs and traces still see after masking
Masking changes what the model receives, but it does not automatically change what the rest of your stack records. When a NeMo Guardrails input rail anonymizes a prompt before it reaches the LLM, the model sees the placeholder text. The application, however, still holds the original user message in its request handling, and any tracing, verbose logging or content capture you have enabled may write the raw text somewhere else. Before go-live, decide for each component whether it sees the original input, the masked input, or both, and confirm that the answer matches your data handling policy.
Check the settings that control this in your own configuration and deployment, not from memory. Confirm whether content capture for traces is enabled, whether verbose logging is turned on in the environment that runs the guardrails server, and whether anonymous usage telemetry is switched off for your deployment. Review the NeMo Guardrails documentation for the current names of these options in the version you run, because they change between releases. The detailed settings, the retention rules for your observability backend and how to test them belong to the sibling page on keeping PII out of traces, logs and telemetry, so treat this section as the checklist of what to verify rather than the configuration guide.
Before go-live, run a test request containing known personal data through the full path and search every place it could land: the application's request log, the guardrails server output, the tracing backend, the metrics store, your reverse proxy and any error reporting tool. Confirm the stored copy contains the masked form or nothing at all, and record the result as evidence for your security and compliance reviewers. Repeat the check after every upgrade, because a new release can change default logging behavior.
How to choose and test the mode for each rail
This sequence turns the block-or-mask question into a documented decision for each rail, backed by test evidence that shows what users see, what the model receives and what the logs record. Reviewers can then trace every mode choice to a test result.
Inventory personal data categories and entry points
Work with the business owner, privacy lead and application engineers to list the personal data categories the assistant may encounter, such as names, contact details, account identifiers and health or payment details. For each category, record where it enters: the user prompt, the model response, or retrieved chunks from knowledge sources. Keep the inventory in a shared document. The step is complete when every category has at least one named entry point and an owner who can answer questions about it.
Decide the mode for each rail
For each combination of category and entry point, choose whether the rail should block the request, mask the value and continue, or log only during evaluation. Blocking suits data that should never reach the model or be shown back to a user. Masking suits cases where the task can still be completed without the raw value. Record the reason beside each choice, and flag any combination where the privacy lead and the product owner disagree before configuration starts.
Configure each rail in config.yml
Enable the chosen input, output and retrieval rails in the
config.ymlfile of the guardrails configuration, and set the detector and action for each one. Keep input, output and retrieval settings in separate sections so a change to one entry point does not silently alter another. Store the file in version control with a reviewer assigned to each change. The step is complete when the configuration loads without errors in the environment that will serve traffic.Run test prompts with synthetic personal data
Build a test set of prompts, model responses and retrieved chunks that contain synthetic personal data for every category in the inventory, including edge cases such as names that are also common words and identifiers that resemble phone numbers. Use only invented values, never production records. Run the set against each rail and save the results with the configuration version. The step is complete when every category and entry point has recorded results, including misses and false positives.
Check the user-facing message
Review what the user sees for each blocked or masked case. Blocked requests should return a clear, non-revealing message that does not repeat the personal data. Masked requests should show the user that content was changed, without leaving partial values that identify anyone. Ask a support representative or product owner to read the messages, and record any wording that confuses users or hints at the detected value. The check passes when no test message echoes the synthetic data.
Check the text passed to the model
Inspect the prompt that reaches the model for masked cases, and confirm that blocked content never reaches it. Compare the raw input with the transformed text for each test case, and confirm that the masking placeholders preserve enough context for the task to still work. Confirm which model endpoint receives the text when a separate detector or hosted service is used. The check passes when no synthetic value appears in the model input unless the mode for that rail explicitly allows it.
Check the log and trace output
Review application logs, traces and any observability backend for the same test cases. Confirm whether raw prompts, responses or retrieved text were recorded, and whether the masked or blocked text was stored instead. Verify the content capture and verbose logging settings in the deployed environment, not only in the development configuration. The check passes when the synthetic values are absent from logs and traces, or the team has documented why a specific field must be retained and who can access it.
Document the decision for reviewers
Write a decision record for each rail that lists the categories covered, the chosen mode, the rationale, the test cases and their results, the configuration version and the named approver. Store the record with the configuration in version control so that reviewers can trace every mode to evidence. Schedule a retest whenever the detector, the configuration or the model changes. The record is complete when a reviewer who was not involved can answer why a given category is blocked or masked on a given entry point.
Security and operational risks of each mode
Blocking and masking both fail in ways that matter to security and operations, and the failures differ by mode. The cards below cover the risks that show up most often when teams choose between rejecting a request and masking it, with the check that confirms each one in your own configuration.
False positives that block legitimate work
Detectors flag names, order numbers, product codes and other identifiers that are not personal data. In blocking mode, each false positive stops a legitimate request outright. Build a test set from real workflows in your environment, run it through every input rail, and record the rate of rejected requests that should have passed before you set thresholds.
NeMo Guardrails docsMasking that leaves partial data in context
Masking replaces only the spans a detector finds, so a name split across tokens, an address without a postcode, or a spelled-out number can reach the model. Confirm which entity types your masking rail covers, then test partial and reformatted identifiers. Decide whether a partially masked request should be allowed, blocked or escalated.
Personal data in logs and traces
Blocking and masking both happen inside the request path, but the raw input may still reach logs, traces or telemetry before or after the rail runs. Check what the server records by default, whether content capture is enabled, and whether verbose logging is on. Confirm the retention period of your observability backend before you test with production-like data.
Inconsistent behavior across rails
Input, output, dialog and retrieval rails may use different detectors, thresholds or actions, so the same identifier can be blocked on input and masked on retrieval. Write a matrix of entity type, rail and expected action, then test each combination. Mismatches between rails are often the source of data leaks that a single-rail test misses.
User confusion when requests fail
A blocked request with a generic refusal gives users no way to know what to remove, so they retry with the same data or contact support. A masked response can also confuse users when placeholders appear in answers. Write the refusal and masking messages with your support team, and test that they explain the next step without repeating the personal data.
Changes after a NeMo Guardrails upgrade
Upgrades can change configuration formats, Python APIs and action behavior, so a rail that blocked a request last month may pass it or mask it differently now. Pin the version you tested, keep a regression set of PII cases, and rerun it before each upgrade. Check the release notes for your version path and confirm the behavior of your configuration after conversion.
- Current release
- 0.25.0
Questions teams ask before deciding between blocking and masking
Which mode should a customer support bot use, blocking or masking?
For most support bots, masking is the better default, because customers often mention an account or contact detail while asking a question the bot can still answer. Blocking fits flows where any personal data in the request is a policy violation, such as a public chat that must never accept card numbers. Many teams use both: mask names and contact details so the conversation continues, and block high-risk identifiers such as payment card numbers or government IDs. Decide per entity type, not for the whole bot, and write that split into your policy before choosing detectors.
Can masking break the answers the model gives?
Yes, and this is the most common engineering surprise. If a placeholder such as a masked name replaces a value the model needs to reason about, answers can become vague, repetitive or wrong. Masking also creates mismatches when the model repeats a placeholder back to the user, or when the same person appears under different placeholders across turns. Test with realistic conversations that reference order numbers, dates and names, and check whether the output rail restores or hides placeholders as your design intends.
What does the work cost, and what drives the effort?
Cost depends on the work you outsource, not on the library, which is open source under Apache 2.0. Main drivers are the number of entity types, how many channels carry data (chat, email, retrieved documents, tool results), whether you run a hosted or self-hosted detector, the volume of sample conversations needed for testing, and how many false positives your users will tolerate. Ongoing costs include detector hosting, compute, and maintenance of patterns as your data changes. Ask any quote to separate one-time configuration and testing from recurring operations, and to name who owns the detector infrastructure.
How long does a pilot of this scope take?
Duration depends on scope: the number of entity types, the number of rails (input, output and retrieval), the detectors chosen, and how much labeled test data exists. A pilot limited to one channel and a short list of entities is shorter than one that covers retrieval and logs. DeployOpen quotes timelines from a written scope, so the fastest way to get a realistic estimate is to define the channels, entities and success criteria first. Ask any provider to state its assumptions about data access and reviews, because those usually set the schedule.
What must our team provide before the work starts?
Three inputs matter most. First, a written data policy that states which entity types to block, which to mask, and what happens to each in prompts, responses and retrieved content. Second, sample data that reflects real conversations, including edge cases such as names that are also product names, and identifiers in your own format. Third, log retention rules for traces and telemetry, since the masking mode determines what reaches your observability backend. Your security and compliance leads should approve these before configuration begins.
Can our own engineers build this in-house?
Yes, if your team has Python experience, can run the library in a controlled environment, and has time to write Colang and test configurations. The NeMo Guardrails project documents configuration with config.yml and Colang files, and it supports Python 3.11, 3.12 and 3.13. The harder parts are usually not the first rail but the evaluation: building test sets, tuning thresholds, reviewing false positives and keeping logs compliant. Confirm your team can own those tasks after handover, or plan for a partner to deliver them with documentation your staff can run.
Which logs and traces will still contain the original personal data?
This depends on where the detector runs and what the framework records by default, so verify it in your own deployment rather than assuming masking covers everything. Check whether traces capture raw input before rails run, whether verbose logging writes prompts, and whether content capture is enabled in your observability setup. Masking at the rail does not clean up earlier records. Ask for a test that sends known personal data through the system and inspects every log sink, trace backend and retention store before go-live.
Where to check the rail behavior in the NeMo Guardrails docs
Before you decide between blocking and masking, confirm how the rails you plan to use behave in the exact version you will run. The official NeMo Guardrails documentation is the place to check configuration keys, rail outcomes and the behavior of PII actions, and the NeMo Guardrails documentation index is the natural starting point. Treat the latest path as a moving target: a page you read last quarter may describe settings that have since changed, so note the documentation date alongside your own test results.
Confirm your version first. The current release is 0.25.0, published on 19 November 2026, and it deprecates the LLMRails class in favor of Guardrails, with removal planned no earlier than 0.27.0. If your configuration or Python code still calls LLMRails, read NVIDIA's 0.25 migration guide before you copy any blocking or masking example into your project. Pin the version in your requirements file, and check the NeMo Guardrails releases page for the change notes that apply to your rails. Ask your implementation team to record the version in the test report for each detector mode you adopt.
How DeployOpen scopes and delivers PII rails for NeMo Guardrails
DeployOpen works on the block or mask decision as a written design choice, not a default setting. We scope which entities, rails and user flows need each behavior, build the rails in your NeMo Guardrails configuration, test both paths and hand over the evidence your security and compliance teams will ask for. Engagements are fixed-scope, with the scope agreed in writing before work starts.
How we scope
- Map each entity type to block, mask or log-only, with the reason recorded for your review
- List the input, output and retrieval paths where personal data can enter or leave the assistant
- Confirm which detector covers each category and which identifiers need custom regex rails
- Agree in writing what the fixed scope includes, what is excluded, and what is deliverable
How we build
- Configure input and output rails in config.yml and Colang so blocked and masked paths behave as scoped
- Set score thresholds and test false positives on names and identifiers in your own sample data
- Confirm what the model receives after masking and keep prompts from exposing original values
- Review trace, log and telemetry settings so blocked or masked content is not stored by default
How we hand over
- Deliver the configuration files, custom actions and test cases used to verify each path
- Document the decision table for block versus mask, including user-facing messages for each outcome
- Provide evidence of tests run on blocked, masked and allowed examples, with results recorded
- Walk your engineering and compliance teams through the design so they can review and maintain it
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover
- Retest rails when NeMo Guardrails releases change configuration, Python APIs or server behavior
- Review detector coverage again when your data types, languages or regulations change
- Confirm the support terms, response expectations and retest scope in the written agreement

