What are Guardrails?
Guardrails are validation checks that run before (pre-hooks) or after (post-hooks) agent execution. They can:- Block malicious input (prompt injection, jailbreaking)
- Detect and mask personally identifiable information (PII)
- Filter harmful or inappropriate content
- Validate output format and content
- Enforce business rules and policies
Quick Start
Add guardrails to an agent:Built-in Guardrails
Agno provides several ready-to-use guardrails:Prompt Injection
Detect and block prompt injection and jailbreaking attempts
PII Detection
Detect and mask personally identifiable information
OpenAI Moderation
Use OpenAI’s moderation API to filter harmful content
Custom Guardrails
Build your own validation logic
Prompt Injection Protection
Prevent users from manipulating agent behavior:Custom Injection Patterns
Add your own patterns to detect:PII Detection and Masking
Protect user privacy by detecting and handling PII:Configurable PII Detection
OpenAI Moderation
Use OpenAI’s moderation API to filter harmful content:Output Guardrails
Validate agent responses before returning them:Custom Guardrails
Create your own validation logic:Multiple Guardrails
Combine multiple guardrails:Error Handling
Handle guardrail violations gracefully:Check Triggers
Guardrails use standard check triggers:Best Practices
Layer Defense
Use multiple guardrails for defense in depth
Fast Checks First
Order guardrails by speed (regex before API calls)
Log Violations
Track blocked requests for security monitoring
Graceful Errors
Provide clear error messages to users
Next Steps
Input Validation
Learn more about input validation patterns
Approval Workflows
Add human approval for sensitive operations
Evaluations
Test your guardrails with evaluations
Tracing
Monitor guardrail performance