# Guardrails (/workflows/blocks/guardrails)





The **Guardrails block** checks content and returns a result. Each block runs one validation type; chain blocks for multiple checks. Validation alone does not choose the next path—connect a Condition to act on it.

<BlockPreview type="guardrails" />

## Validate before parsing [#validate-before-parsing]

<WorkflowPreview workflow="GUARDRAILS_JSON_WORKFLOW" />

Select **Valid JSON**, check `<agent.content>`, and branch on `<guardrails.passed>` before parsing it in Function. This checks JSON syntax, not a schema's required fields or types.

## Configuration [#configuration]

Set **Content to Validate** to text or an earlier output, then select **Validation Type**.

### Valid JSON [#valid-json]

Passes when the content parses as JSON. Invalid content returns `passed: false` and a parse error. Use a Function after this check if you also need schema validation.

### Regex match [#regex-match]

Enter **Regex Pattern**, for example an email pattern:

```text
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
```

Patterns use RE2's linear-time engine. Lookahead, lookbehind, and backreferences are unsupported and fail validation. To require that content does not contain a pattern, match the pattern and invert `passed` in a Condition.

### Hallucination check [#hallucination-check]

Select **Knowledge Base** and **Model**. There is no default model. The block retrieves relevant chunks and asks the model how well they support the answer.

| Field | Behavior |
| - | - |
| **Confidence** | Minimum passing score from 0 to 10; default 3. |
| **Top K** | Advanced number of retrieved chunks; default 5, maximum 20. More chunks add context, latency, and tokens. |

The scale runs from 0 (ungrounded) to 10 (fully supported according to the model). It is a model judgment, not proof that every claim is correct. No relevant retrieved context fails the check. Sim Cloud supplies credentials for supported hosted models; other models or deployments can require your own.

### PII detection [#pii-detection]

Detect personally identifiable information with [Microsoft Presidio](https://microsoft.github.io/presidio/). Choose the **PII Types to Detect**, **Action**, and **Language**.

* **Common** includes names, email, phone, credit cards, IP addresses, and other identifiers.
* **Language** defaults to English. English, Spanish, Italian, Polish, and Finnish have configured NLP models; choose the language matching the input. Entity availability can vary by language.
* **Custom Patterns** adds Name, Pattern, and Replacement rows for identifiers not covered by the built-in selection. These PII recognizers use a different engine from Regex Match; do not assume their pattern support is identical.

With no selected built-in types and no custom patterns, detection uses the analyzer's supported types.

The picker groups these regional identifiers. Availability depends on the selected language.

| Region | Identifiers |
| - | - |
| United States | Social Security Number (SSN), driver's license, passport, bank account, Individual Taxpayer Identification Number (ITIN) |
| United Kingdom | NHS number, National Insurance Number |
| Spain | NIF and NIE numbers |
| Italy | Fiscal code, driver's license, VAT code, passport, identity card |
| Poland | PESEL number |
| Singapore | NRIC/FIN, Unique Entity Number (UEN) |
| Australia | Business Number (ABN), Company Number (ACN), Tax File Number (TFN), Medicare number |
| India | Permanent Account Number (PAN), Aadhaar number, vehicle registration, voter ID, passport |
| Finland | Personal Identity Code |

| Action | Result when PII is found |
| - | - |
| **Block Request** (default) | `passed: false`, detected entities, and an error summary |
| **Mask PII** | Replaced text in `maskedText`; `passed: true` when masking succeeds |

With no PII found, Mask returns the original text. Read `detectedEntities` to distinguish no detection from successful masking.

<Callout type="warn">
  Use `<guardrails.maskedText>` downstream in Mask mode. The original content is still available as `<guardrails.input>`; masking does not replace it everywhere in the run.
</Callout>

## Outputs [#outputs]

| Reference | Value |
| - | - |
| `<guardrails.passed>` | Validation outcome; for Mask, whether masking succeeded |
| `<guardrails.validationType>` | Check that ran |
| `<guardrails.input>` | Original checked content |
| `<guardrails.error>` | Failure message, when present |
| `<guardrails.score>` / `<guardrails.reasoning>` | Grounding score and explanation for Hallucination Check |
| `<guardrails.detectedEntities>` | PII entities with type, location, detected text, and confidence |
| `<guardrails.maskedText>` | Masked text in Mask mode |

## Check grounding [#check-grounding]

<WorkflowPreview workflow="GUARDRAILS_HALLUCINATION_WORKFLOW" />

Use `passed` for the configured threshold, or `score` for an explicit downstream comparison. Hallucination checks run synchronously; choose the model and chunk count according to the latency your workflow allows.

## Block PII in input [#block-pii-in-input]

<WorkflowPreview workflow="GUARDRAILS_PII_WORKFLOW" />

Branch on `passed` to process clean input or reject detected PII. Selecting only the types relevant to your task keeps the check focused.

## Related docs [#related-docs]

* [Condition](/workflows/blocks/condition)
* [Function](/workflows/blocks/function)
* [Credentials and execution-log protection](/platform/credentials)
