> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Security

> Protect your agents from misuse

Agents include security features to prevent misuse and protect data.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    Input([Input]) --> Agent[Agent]
    Agent --> Safe([Safe Output])

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff

    class Agent agent
    class Input,Safe tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    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
    ```
  </Step>

  <Step title="With Configuration">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    const agent = new Agent({
      security: {
        blockInjection: true,
        blockPII: true,
        maxTokens: 4000
      }
    });
    ```
  </Step>
</Steps>

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Security
    participant Agent
    
    User->>Security: Potentially unsafe input
    Security->>Security: Validate input
    alt Safe
        Security->>Agent: Process request
        Agent->>Security: Generate response
        Security->>Security: Filter output
        Security-->>User: Safe response
    else Unsafe
        Security-->>User: Blocked
    end
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// 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

<Card title="GuardrailConfig" icon="code" href="/docs/sdk/reference/typescript/classes/GuardrailConfig">
  Complete configuration options
</Card>

<Card title="Guardrails Module" icon="shield" href="/docs/sdk/reference/typescript/modules/guardrails">
  Full module documentation
</Card>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Enable in production">
    Always enable security for user-facing agents.
  </Accordion>

  <Accordion title="Limit tool access">
    Only give agents the tools they actually need.
  </Accordion>

  <Accordion title="Monitor usage">
    Track interactions to detect unusual patterns.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Guardrails" icon="shield" href="/docs/js/guardrails">
    Input/output validation
  </Card>

  <Card title="Approval" icon="shield-check" href="/docs/js/approval">
    Human oversight
  </Card>
</CardGroup>
