> ## 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.

# Guardrail Config • Rust AI Agent SDK

> GuardrailConfig: Configuration for guardrails.

# GuardrailConfig

> Defined in the [**guardrails**](../modules/guardrails) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Configuration for guardrails.

## Fields

| Name                | Type                   | Description                             |
| ------------------- | ---------------------- | --------------------------------------- |
| `on_failure`        | `GuardrailAction`      | Action to take on failure               |
| `max_retries`       | `usize`                | Maximum retries if action is Retry      |
| `fallback_response` | `Option&lt;String&gt;` | Fallback response if action is Fallback |
| `log_results`       | `bool`                 | Whether to log validation results       |
| `error_template`    | `Option&lt;String&gt;` | Custom error message template           |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> Self
```

Create new config

### `on_failure`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn on_failure(mut self, action: GuardrailAction) -> Self
```

Set failure action

**Parameters:**

| Name     | Type              |
| -------- | ----------------- |
| `action` | `GuardrailAction` |

### `max_retries`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn max_retries(mut self, retries: usize) -> Self
```

Set max retries

**Parameters:**

| Name      | Type    |
| --------- | ------- |
| `retries` | `usize` |

### `fallback_response`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn fallback_response(mut self, response: impl Into<String>) -> Self
```

Set fallback response

**Parameters:**

| Name       | Type                      |
| ---------- | ------------------------- |
| `response` | `impl Into&lt;String&gt;` |

### `log_results`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn log_results(mut self, log: bool) -> Self
```

Set log results

**Parameters:**

| Name  | Type   |
| ----- | ------ |
| `log` | `bool` |

### `error_template`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn error_template(mut self, template: impl Into<String>) -> Self
```

Set error template

**Parameters:**

| Name       | Type                      |
| ---------- | ------------------------- |
| `template` | `impl Into&lt;String&gt;` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/guardrails/mod.rs#L199">
  `praisonai/src/guardrails/mod.rs` at line 199
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Guardrails" icon="shield" href="/docs/rust/guardrails" />

  <Card title="Rust Approval" icon="check" href="/docs/rust/approval" />

  <Card title="Rust Security" icon="lock" href="/docs/rust/security" />

  <Card title="Rust Configuration" icon="gear" href="/docs/rust/configuration" />

  <Card title="Rust Installation" icon="download" href="/docs/rust/installation" />
</CardGroup>
