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

# Guardrails Overview

> Keep your agent safe and compliant

Guardrails are safety constraints that protect your customers and brand by defining what your agent cannot do and when it should escalate to humans.

{/* Screenshot: Guardrails page showing escalation rules and restrictions tabs */}

## What are Guardrails?

Guardrails are the safety net for your AI agents. They define boundaries and trigger actions when those boundaries are approached.

### Two Types

| Type                 | Purpose                       | When Triggered                                       |
| -------------------- | ----------------------------- | ---------------------------------------------------- |
| **Escalation Rules** | Hand off to humans            | Customer is upset, legal question, VIP, complexity   |
| **Restrictions**     | Block specific actions/topics | Forbidden topics, unsafe promises, confidential info |

## Escalation Rules

Define when the agent should stop and hand off to a human:

**Examples:**

| Rule           | Description                                          |
| -------------- | ---------------------------------------------------- |
| Angry Customer | Customer expresses frustration or mentions canceling |
| Legal Question | Questions about contracts, liability, or legal terms |
| VIP Customer   | Conversations from enterprise or high-value accounts |
| Complex Issue  | Agent cannot confidently resolve after attempts      |
| Human Request  | Customer explicitly asks to speak with a person      |

When an escalation rule triggers:

1. Agent stops processing
2. Sends an appropriate message to the customer
3. Creates an internal note with context
4. Routes to human queue

## Restrictions

Define absolute limits on what the agent cannot do:

**Examples:**

| Restriction              | Response When Triggered                                                                              |
| ------------------------ | ---------------------------------------------------------------------------------------------------- |
| No refund promises       | "I'd love to help! Let me connect you with our billing team who can review refund requests."         |
| No competitor discussion | "I'm focused on how we can help you. Let me tell you about what makes us great."                     |
| No internal pricing      | "For custom pricing, please contact our sales team at [sales@example.com](mailto:sales@example.com)" |
| No medical/legal advice  | "I can't provide medical/legal advice, but I can help you find appropriate resources."               |

Restrictions are the highest priority — they're checked before anything else.

## Priority Order

Guardrails are evaluated in this order:

```
1. Restrictions (highest priority)
        ↓
   If triggered → Block/Redirect
        ↓
2. Escalation Rules
        ↓
   If triggered → Escalate
        ↓
3. Normal Processing
        ↓
   Generate response
```

## Detection Methods

Guardrails can detect triggers using:

| Method       | Best For                           | Example                                        |
| ------------ | ---------------------------------- | ---------------------------------------------- |
| **AI-based** | Complex context, sentiment, intent | "Customer is frustrated about repeated issues" |
| **Keyword**  | Specific words or phrases          | "cancel", "lawsuit", "speak to manager"        |
| **Regex**    | Structured patterns                | Email addresses, order numbers                 |

{/* Screenshot: Guardrail configuration showing detection method options */}

## Testing Guardrails

Each guardrail includes a built-in playground:

{/* Screenshot: Guardrail testing panel with test input and result */}

1. Open the guardrail configuration
2. Enter test messages
3. See if the guardrail triggers
4. Refine detection criteria

## Guardrails vs Guidelines

| Guardrails                        | Guidelines          |
| --------------------------------- | ------------------- |
| Safety constraints                | Communication style |
| Hard limits                       | Soft guidance       |
| Trigger actions (escalate, block) | Shape responses     |
| Evaluated per-message             | Always applied      |

**Guardrail:** "Never discuss competitor pricing" → Blocks the topic
**Guideline:** "Be professional and helpful" → Shapes all responses

## Common Guardrail Patterns

### Safety Net

Catch situations that need human judgment:

* Angry or threatening language
* Legal or compliance topics
* Account security concerns
* Complex edge cases

### Brand Protection

Prevent brand damage:

* Competitor discussions
* Unauthorized promises
* Confidential information
* Off-brand responses

### Compliance

Meet regulatory requirements:

* Privacy requests (GDPR, CCPA)
* Financial advice disclaimers
* Medical/legal limitations
* Age-restricted content

## Next Steps

<CardGroup cols={2}>
  <Card title="Escalation Rules" icon="arrow-up-right-from-square" href="/guardrails/escalation-rules">
    Define when to hand off
  </Card>

  <Card title="Restrictions" icon="ban" href="/guardrails/restrictions">
    Set hard limits
  </Card>
</CardGroup>
