Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Guardrails System
Guardrails provide output validation and quality assurance for agent tasks, ensuring results meet specified criteria before being accepted.Overview
Guardrails ensure task outputs meet quality and safety criteria through:- Function-based validation for structured checks
- LLM-based validation for natural language criteria
- Automatic retry mechanisms for failed validations
- Custom validation logic for specific requirements
Sync vs Async Parity: Guardrails now work uniformly in both sync (
.start() / .run()) and async execution paths. Previously, async execution bypassed guardrail validation.Quick Start
Guardrail Types
Function-Based Guardrails
Function guardrails provide programmatic validation:LLM-Based Guardrails
LLM guardrails use natural language for validation:Advanced Features
Retry Configuration
Configure retry behaviour for failed validations (works in both sync and async execution paths):completed.
How Retries Work
When a guardrail validation fails:- Before PR #1514: Async execution bypassed retry logic
- After PR #1514: Both sync and async execution paths properly retry failed validations
task.retry_count, sets task.status = "in progress", logs the retry, and continues the execution loop. On final failure after max_retries, it raises an exception. When a guardrail returns a modified TaskOutput or string, the downstream task.result and any memory callbacks receive the modified value, not the original.
Cached Field Clearing: When a guardrail modifies string output, cached fields like
json_dict and pydantic are automatically cleared on TaskOutput to prevent stale cached values from being used by structured output consumers.Composite Guardrails
Combine multiple validation criteria:Guardrail Results
Access detailed validation results:Use Cases
Content Safety
Ensure generated content is safe and appropriate
Data Validation
Validate analysis results and reports
Code Quality
Ensure generated code is safe and functional
Compliance
Meet regulatory and policy requirements
Integration Patterns
With Agents
With Dynamic Guardrails
Best Practices
Clear Criteria
- Define specific, measurable criteria
- Document validation requirements
- Provide helpful error messages
- Include examples of valid output
Balanced Approach
- Use function guardrails for simple checks
- Reserve LLM guardrails for complex validation
- Implement caching for repeated validations
Retry Strategy
- Set appropriate retry limits
- Provide detailed failure reasons
- Suggest corrections when possible
Testing
- Log validation failures
- Handle edge cases gracefully
- Test guardrails independently
- Verify both pass and fail cases
- Check retry behaviour
- Monitor validation performance
Complete Example
Next Steps
Learn about human-in-the-loop approvals
Explore advanced task configurations

