Redact PII with Sentinel
Configure Sentinel to detect and redact PII instead of blocking
This tutorial uses Sentinel’s PII detection and the redact action.
If you want to understand all Sentinel actions (block, flag, redact, escalate) and how they interact with inputs, outputs, and tool calls, see:
/docs/guides/sentinel-guardrails/docs/api-reference/sentinel
What this tutorial covers
- Enabling Sentinel with
action_on_violation: "redact" - Direct PII detection and redaction with
PIIDetector - Supported PII types and redaction behavior
1) Install and initialize
2) Enable Sentinel with redaction
With action_on_violation: "redact", Sentinel masks detected PII (for example: email addresses, SSNs, credit cards) and continues execution.
In redact mode:
- Sentinel does not raise
AgentValidationErrorfor PII violations. - Redaction tokens like
[EMAIL_REDACTED]replace the sensitive spans.
3) Quick redaction example
Input:
Redacted:
4) Direct PII detection
If you’re using SentinelEngine directly, the redacted content is exposed on GuardrailResult.redacted_content.
5) Common PII types
Sentinel supports redaction for the following categories:
- Contact
- Emails
- Phones (US/UK/EU/intl)
- Government identifiers
- SSNs
- Passports
- Financial
- Credit cards
- IBANs
- EU VAT numbers
- Network
- IP addresses
- Personal attributes
- Dates of birth
- Addresses
- Names
Examples and redaction tokens
| PII type | Example | Redaction token |
|---|---|---|
john@example.com | [EMAIL_REDACTED] | |
| Phone | +44 20 7123 4567 | [PHONE_REDACTED] |
| SSN | 123-45-6789 | [SSN_REDACTED] |
| Credit card | 4532-0151-1283-0366 | [CREDIT_CARD_REDACTED] |
| IBAN | DE89 3704 0044 0532 0130 00 | [IBAN_REDACTED] |
| EU VAT | DE123456789 | [VAT_REDACTED] |
| IP address | 192.168.1.100 | [IP_REDACTED] |
| Passport | AB1234567 | [PASSPORT_REDACTED] |
| Date of birth | 1990-01-15 | [DOB_REDACTED] |
| Address | 123 Main St, Apt 4 | [ADDRESS_REDACTED] |
| Name | Dr. Jane Doe | [NAME_REDACTED] |
Credit cards are validated using the Luhn algorithm to reduce false positives.
Note: PII field names in the
detect()return dict are singular:phone,ssn,credit_card,ip_address,iban,vat,passport,dob,address,name.