Create a PII guardrail
Start from the PII protection template, add an employee-number pattern rule, test both, roll them out in monitor mode and then enforce them.
After reading this page you will be able to:
- Create a guardrail from a template
- Preview it on sample sentences
- Move from monitor to enforce with evidence from the audit log
Beginner20 minGovernanceDocker
Prerequisites
- A running Liyagent instance with an agent that calls a model (Liya is fine).
Steps
- Open Guardrail rules → Create guardrail and pick the PII protection template (direction both, action mask). Name it
pii-lab. - Under Rollout, keep Monitor first (recommended). Under Scope → Agents, enter the agent's id, or leave it blank for every agent. Choose Create guardrail.
- Create a second rule for the employee number: Create guardrail → Start blank, name
pii-lab-emp, policy Custom patterns. Choose + Add pattern: nameemployee-number, patternEMP-[0-9]{6}, Mask. Keep Monitor first and create it. - In the test panel on the Guardrail rules list, enter
Please reset MFA for sam@example.com, EMP-204511, phone +44 20 7946 0000and choose Run against enabled policies. The email and phone number come frompii-lab, and the employee number frompii-lab-emp. - Send the same sentence to the agent on its Playground tab. The answer is unchanged (monitor mode), but the audit log has findings.
- Open Audit log and filter Finding policy =
pii-lab(thenpii-lab-emp). Confirm each finding is right. - On the list, open each rule's menu and choose Enforce now. Send the sentence again: the model now sees masked values.
Check your work
curl -b cookies.txt -X POST http://127.0.0.1:8787/api/guardrails/preview \
-H "Content-Type: application/json" -d '{"text":"EMP-204511 cannot log in"}'The response names pii-lab-emp and its employee-number match: under monitored while the rule is in monitor mode, and under applied once it is enforced.