Skip to main content
Agents include security features to prevent misuse and protect data.

Quick Start

1

Enable Security

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
2

Custom Rules

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

FeatureProtection
blockInjectionStops prompt manipulation
blockPIIFilters personal data
blockPatternsCustom regex filters
maxTokensLimits output size
rateLimitControls request frequency

API Reference

GuardrailConfig

Complete configuration options

Guardrails Module

Full module documentation

Best Practices

Always enable security for user-facing agents.
Only give agents the tools they actually need.
Track interactions to detect unusual patterns.