Overview
Follow these best practices to build secure, reliable, and maintainable AI agent systems with AgentWarden.Architecture Patterns
1. Single Responsibility Agents
Create separate agents for different purposes rather than one “super agent”.- Better security isolation
- Clearer audit trails
- Easier to debug
- Simpler permission management
2. Check-Execute-Log Pattern
Always follow this pattern for agent actions:- ❌ Don’t execute without checking
- ❌ Don’t check but forget to log
- ❌ Don’t log only successes
3. Tiered Permissions
Use tiered permissions for different risk levels:- Automatic escalation for high-risk actions
- Reduce approval bottlenecks for low-risk actions
- Clear risk boundaries
Permission Management
4. Use Descriptive Action Names
Action names should clearly indicate what they do:stripe.refund- Stripe service, refund operationdatabase.users.delete- Database service, users resource, delete operationapi.sendgrid.email.send- API integration, SendGrid, email resource, send operation
5. Environment-Specific Permissions
Use different permissions for different environments:6. Regularly Review Permissions
Set up a quarterly permission audit:Context and Logging
7. Provide Rich Context
Always include comprehensive context for permission checks and logs:- Approvers can make informed decisions
- Better debugging when issues occur
- Compliance and audit requirements
- Analytics and reporting
8. Structured Error Context
When logging failures, include structured error information:9. Log Denials Too
Even if permission was denied, log it:- Track attempted unauthorized actions
- Identify misconfigured permissions
- Security monitoring
- Detect potential abuse
Security
10. Never Expose API Keys
Keep API keys secure:- Store in environment variables
- Use secrets managers (AWS Secrets Manager, HashiCorp Vault)
- Never commit to version control
- Rotate keys regularly (every 90 days)
- Use different keys per environment
11. Fail-Safe Defaults
When in doubt, deny:12. Least Privilege Principle
Grant only the minimum permissions needed:- Begin with minimal permissions
- Monitor for denied actions
- Add permissions as needed
- Remove unused permissions
Performance
13. Reuse AgentWarden Instance
Create one instance and reuse it:14. Implement Caching (Carefully)
Cache permission checks for identical actions:- Only cache for short periods (30-60 seconds)
- Clear cache when permissions change
- Don’t cache approval-required actions
- Monitor cache hit rates
15. Batch Operations
For bulk operations, check once and execute many:Testing
16. Test Permission Logic
Write tests for permission scenarios:17. Use Test API Keys
AgentWarden provides test API keys for development:- Prefix:
test_ - Don’t count against plan limits
- Isolated test data
- Can be shared with developers
Monitoring
18. Track Key Metrics
Monitor these metrics:- Permission check latency
- Denial rate by action
- Approval response time
- Error rate
- Rate limit hits
19. Set Up Alerts
Alert on anomalies:Documentation
20. Document Your Agents
Keep documentation for each agent:Checklist
Use this checklist for every new agent:Quick Reference
| Practice | Do | Don’t |
|---|---|---|
| Agent Design | One agent per purpose | One super agent |
| Permissions | Least privilege, specific actions | Broad wildcards |
| Security | Environment variables, fail-safe | Hardcoded keys, fail-open |
| Context | Rich, detailed context | Minimal context |
| Logging | Log everything (success, fail, deny) | Only log successes |
| Errors | Handle gracefully, retry with backoff | Ignore errors |
| Testing | Test all permission scenarios | No tests |
| Monitoring | Track metrics, set alerts | No monitoring |