Create an input guardrail to enforce a content policy on the messages users send to Optimizely Opal. This article covers writing a rule, training a classifier, tuning the results, and testing the guardrail.
Access guardrails
To access guardrails in Opal, go to Agents > Input Guardrails.
Create a guardrail
To create a guardrail, complete the following steps:
- Follow the steps in the Access guardrails section.
- Click Create Guardrail.
- Enter a Name for the guardrail, such as No competitor discussions.
- Enter the Rule in natural language. The rule describes the policy you want to enforce. See Write effective input guardrail rules.
- (Optional) Enter a Block message that users see when Opal blocks their input.
-
Click Create.
When you leave the block message blank, Opal generates a contextual, one-sentence explanation for each blocked message. This dynamic message tells the user why Opal 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.
- Follow the steps in the Access guardrails section.
- Click the guardrail version you want to train.
-
Click Train to start the training pipeline.
-
Monitor the version status as it moves from Untrained to Training to Ready. Status updates display in real time.
Training runs in the background and takes several minutes. Opal runs one training job per instance at a time. When a job does not finish within 15 minutes, Opal retries it automatically up to three times before it marks the version Failed.
Opal 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:
- Follow the steps in the Access guardrails section.
- Click the guardrail version whose training data you want to review.
-
Expand Training Data to see the generated examples grouped by policy. Each example is labeled Blocked or Allowed.
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:
-
Click Add example.
- Enter the Prompt. The prompt is the message the guardrail should judge.
- Select Blocked or Allowed for the Decision.
-
(Conditional) When you set the Decision to Blocked, select the Rule aspect.
- Click Add.
-
Click Save changes.
- 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:
- (Optional) Enter a search term in the Search examples field to filter the list.
-
Click the example you want to edit.
- Update the example.
- (Conditional) When you set the Decision to Blocked, select the Rule aspect.
- Click Save changes.
- 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:
- (Optional) Enter a search term in the Search examples field to filter the list.
-
Click Delete for the example you want to remove.
- Click Save changes.
- 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.
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.
- Follow the steps in the Access guardrails section.
- Click the guardrail version you want to test.
-
Click Test run.
- Enter sample messages in the Test run panel.
-
Click Test.
-
Review whether Opal classifies each message as blocked or allowed. Blocked messages display the block message, either static or dynamically generated.
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 or Assign an input guardrail to a specialized agent to use it.
Additionally, see the following related documentation:
Article is closed for comments.