---
title: Create and train an input guardrail
slug: agent-platform/docs/create-and-train-an-input-guardrail
docTags: 
createdAt: 2026-08-26T22:49:32.000Z
---

Create an input guardrail to enforce a content policy on the messages users send to Optimizely Agent Platform. This article covers writing a rule, training a classifier, tuning the results, and testing the guardrail.

## Access guardrails

To access guardrails in Agent Platform, go to **Agents > Input Guardrails**.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/ookqIocpNWIJixwjniiJ4_access-guardrails.png)

## Create a guardrail

To create a guardrail, complete the following steps:

1. Follow the steps in the [Access guardrails](docId:-seHtlUToZb5C0L8Bmkvu) section.
2. Click **Create Guardrail**.
3. Enter a **Name** for the guardrail, such as *No competitor discussions*.
4. Enter the **Rule** in natural language. The rule describes the policy you want to enforce. See [Write effective input guardrail rules](docId\:fYlE27iwPJ1dFXI3n7iFx).
5. (Optional) Enter a **Block message** that users see when Agent Platform blocks their input.
6. Click **Create**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/IPHs8iuU9H9KlpjSG-VuQ_create-guardrail.png" size="100" isUploading="false" position="center" width="1450" height="974" darkWidth="1450" darkHeight="974" showCaption="false" indent="1"}

When you leave the block message blank, Agent Platform generates a contextual, one-sentence explanation for each blocked message. This dynamic message tells the user why Agent Platform blocked their message without revealing internal policy details. To switch to a static message later, edit the guardrail and enter one.

Each save creates an immutable version. Create new versions of the same guardrail to update rules without losing previous configurations.

## Train the guardrail

After you create a guardrail version, train a classifier to enforce it.

1. Follow the steps in the [Access guardrails](docId:-seHtlUToZb5C0L8Bmkvu) section.
2. Click the guardrail version you want to train.
3. Click **Train** to start the training pipeline.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/G9HueCVF0j3hLf34cYuL4_train-guardrail.png" size="100" isUploading="false" position="center" width="1416" height="972" darkWidth="1416" darkHeight="972" showCaption="false" indent="1"}

4. Monitor the version status as it moves from **Untrained** to **Training** to **Ready**. Status updates display in real time.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/s2RTcaq_rhc-FnCqLycHC_monitor-guardrail.png" size="100" isUploading="false" position="center" width="1430" height="398" darkWidth="1430" darkHeight="398" showCaption="false" indent="1"}

Training runs in the background and takes several minutes. Agent Platform runs one training job per instance at a time. When a job does not finish within 15 minutes, Agent Platform retries it automatically up to three times before it marks the version **Failed**.

Agent Platform decomposes your rule into a maximum of five atomic policies. When a rule is too broad and decomposes into more than five policies, training fails. To resolve this, simplify or narrow your rule text and train again.

## Review training data

After training, review and refine the generated examples to improve accuracy. To view the training data, complete the following steps:

1. Follow the steps in the [Access guardrails](docId:-seHtlUToZb5C0L8Bmkvu)  section.
2. Click the guardrail version whose training data you want to review.
3. Expand **Training Data** to see the generated examples grouped by policy. Each example is labeled **Blocked** or **Allowed**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/k410Eq3BD3xViXlIKuaIq_review-training-data.png" size="100" isUploading="false" position="center" width="1404" height="1430" darkWidth="1404" darkHeight="1430" showCaption="false" indent="1"}

To generate a fresh set of examples, click **Regenerate Training Data**. This action creates a new version with fresh examples.

### Add training data

To add your own example training data, complete the following steps:

1. Click **Add example**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/OZ0lFqbCJ5SGQ-qlBfyQa_add-training-example.png" size="100" isUploading="false" position="center" width="1404" height="550" darkWidth="1404" darkHeight="550" showCaption="false" indent="1"}

2. Enter the **Prompt**. The prompt is the message the guardrail should judge.
3. Select **Blocked** or **Allowed** for the **Decision**.
4. (Conditional) When you set the **Decision** to **Blocked**, select the **Rule aspect**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/TrOG4A9CMVq3Zl4VSGl1__add-exampe.png" size="70" isUploading="false" position="center" width="584" height="716" darkWidth="584" darkHeight="716" showCaption="false" indent="1"}

5. Click **Add**.
6. Click **Save changes**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/1lNZiq9JkWvUjmWdustu3_save-changes-to-guardrail.png" size="100" isUploading="false" position="center" width="1450" height="998" darkWidth="1450" darkHeight="998" showCaption="false" indent="1"}

7. Click **Train**.

Saving changes to training data creates an untrained draft version. Retrain the guardrail for the changes to take effect.

### Edit training data

To edit an individual training example, complete the following steps:

1. (Optional) Enter a search term in the **Search examples** field to filter the list.
2. Click the example you want to edit.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/NxgAyfgRBA73TbVTrt0Zb_edit-training-data.png" size="100" isUploading="false" position="center" width="1340" height="1002" darkWidth="1340" darkHeight="1002" showCaption="false" indent="1"}

3. Update the example.
4. (Conditional) When you set the **Decision** to **Blocked**, select the **Rule aspect**.
5. Click **Save changes**.
6. Click **Train**.

Saving changes to training data creates an untrained draft version. Retrain the guardrail for the changes to take effect.

### Delete training data

To delete an individual training example, complete the following steps:

1. (Optional) Enter a search term in the **Search examples** field to filter the list.
2. Click **Delete** for the example you want to remove.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/UQjtdh0ybdPJFxbRG9lgf_delete-training-data.png" size="100" isUploading="false" position="center" width="1338" height="940" darkWidth="1338" darkHeight="940" showCaption="false" indent="1"}

3. Click **Save changes**.
4. Click **Train**.

Saving changes to training data creates an untrained draft version. Retrain the guardrail for the changes to take effect.

## Adjust sensitivity

After training, adjust the sensitivity for each policy within the guardrail by selecting **Low**, **Medium**, or **High**. The level you select changes how strictly the classifier enforces each policy.

- **Low** – Allows more messages through. Reduces false positives but misses some violations.
- **Medium** – Blocks clear violations while allowing borderline messages. Balances false positives and false negatives.
- **High** – Blocks more messages, including borderline cases. Reduces false negatives but increases false positives.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/NEFSf9IGIimivVtN_rwRH_adjust-sensitivity.png" size="100" isUploading="false" position="center" width="1348" height="570" darkWidth="1348" darkHeight="570" showCaption="false" indent="1"}

Unlike edits to training data, sensitivity adjustments apply when you click **Save changes** and do not require retraining.

## Test the guardrail

Before you activate a guardrail, test it against sample messages to verify it works as expected.

1. Follow the steps in the [Access guardrails](docId:-seHtlUToZb5C0L8Bmkvu) section.
2. Click the guardrail version you want to test.
3. Click **Test run**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/N83BQ6R_19xpHCP0Spvjf_test-guardrail.png" size="100" isUploading="false" position="center" width="1418" height="966" darkWidth="1418" darkHeight="966" showCaption="false" indent="1"}

4. Enter sample messages in the **Test run** panel.
5. Click **Test**.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/7kLoBanFq8njbhfKbK00F_click-test.png" size="100" isUploading="false" position="center" width="2010" height="934" darkWidth="2010" darkHeight="934" showCaption="false" indent="1"}

6. Review whether Agent Platform classifies each message as blocked or allowed. Blocked messages display the block message, either static or dynamically generated.

::Image[]{src="https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/xJ92dNJ0B0lAyRfZYPtL__guardrail-test-output.png" size="60" isUploading="false" position="center" width="652" height="1070" darkWidth="652" darkHeight="1070" showCaption="false" indent="1"}

Adjust sensitivity or retrain the guardrail when the results do not match your expectations.

## Next steps

When your guardrail is ready, [Activate an input guardrail for your instance](docId:2LMsn2ASefUWAAmkCGuPh) or [Assign an input guardrail to a specialized agent](docId:5gldqAfbXf_LZHPLZXwOC) to use it.

:::hint{type="info"}
**Note**

If you use Opti ID, administrators can turn off generative AI in the Opti ID Admin Center. See [Turn generative AI off across Optimizely applications](docId\:X5U0kKD2azV5cIdNqwGNj).
:::
