Security
Protect your agents from misuse
Agents include security features to prevent misuse and protect data.
Quick Start
- Simple Usage
typescript import { Agent } from 'praisonai'; const agent = new Agent({ instructions: 'You are a helpful assistant', security: true // Enable all protections }); await agent.chat('Ignore previous instructions and...'); // Prompt injection blocked - With Configuration
typescript const agent = new Agent({ security: { blockInjection: true, blockPII: true, maxTokens: 4000 } });
User Interaction Flow
Configuration Levels
// Level 1: Bool - Enable all protections
const agent = new Agent({
security: true
});
// Level 2: Array - Specific protections
const agent = new Agent({
security: ['injection', 'pii', 'profanity']
});
// Level 3: Dict - Full control
const agent = new Agent({
security: {
blockInjection: true,
blockPII: true,
blockPatterns: [/password/i, /\b\d{16}\b/], // Credit cards
maxTokens: 4000,
rateLimit: 10 // Per minute
}
});Security Features
| Feature | Protection |
|---|---|
blockInjection | Stops prompt manipulation |
blockPII | Filters personal data |
blockPatterns | Custom regex filters |
maxTokens | Limits output size |
rateLimit | Controls request frequency |
API Reference
GuardrailConfigComplete configuration options
Guardrails ModuleFull module documentation
Best Practices
Enable in production
Always enable security for user-facing agents.
Limit tool access
Only give agents the tools they actually need.
Monitor usage
Track interactions to detect unusual patterns.