AI Agent1 input → 2 outputs
Guardrails
Applies intelligent safety guardrails to AI responses using Regex patterns or AI-enhanced logic for PHI redaction, content moderation, and quality checks.
Inputs
Outputs
- Pass (Safe/Redacted)
- Fail (Block/Violation)
Configuration
- Mode
-
- Regex-Only (Fast): Local pattern matching (PHI, Custom Regex). No API calls.
- AI-Enhanced (Intelligent): Uses LLM to reason about context, tone, and moderation.
- Rules (AI Mode)
-
- PHI Redaction: Intelligent de-identification.
- Content Moderation: Block harmful/illegal content.
- Tone Check: Rewrite for professional tone.
- Custom Rule: User-defined logic with templating (e.g.
{{msg.checkType}}).
Typical Usage
Healthcare Agent Flow
┌────────────┐ ┌──────────┐ ┌────────────────┐
│ User Query │──▶│ AI Model │──▶│ AI Agent │
└────────────┘ └──────────┘ └───────┬────────┘
│
┌────────────────────────────┘
▼
┌──────────────┐ ┌─────────────────┐ ┌────────────┐
│ Guardrails │──▶│ Update History │──▶│ Response │
└──────┬───────┘ └─────────────────┘ └────────────┘
│
▼ (Output 2: Block/Fail)
┌──────────┐
│ BLOCKED │
└──────────┘
Examples
1. Redaction (Regex or AI)
Input: "Patient John Doe (DOB 01/01/1980) has diabetes."
Output: "Patient [REDACTED] (DOB [REDACTED]) has diabetes."
2. Blocking (Content Moderation)
Input: "I hate you and want to hurt someone."
Output (Port 2):
{
"payload": {
"error": "GUARDRAIL BLOCK: Hate speech detected. Please rewrite..."
}
}
3. Custom Rule with Templating
Rule: "Block if text mentions {{msg.bannedFruit}}"
msg.bannedFruit = "apple";
Input: "I like apple pie."
Output (Port 2): "GUARDRAIL BLOCK: Text mentions apple."
Best Practices
- Healthcare: Always place Guardrails after AI Agent.
- Performance: Use Regex-Only for high-volume data.
- Fail-Safe: Connect Output 2 to an error handler or back to the AI (with a prompt to retry).
- Testing: Verify custom rules with known bad inputs before production.