Configure guardrails for an agent in the agent editor to route intents, mask personal data, filter content, and block prompt injection on the text that enters and leaves the agent.
The configured guardrail policy applies to the whole agent bundle, including delegated work. Agent Studio stores the policy in the guardrails.yaml file at the root of the bundle. The file appears in the Files pane after you save the policy. For more information on how guardrails evaluate checks and handle failures, see Guardrails.
- Make sure that your user has the Admin or Builder role. See User roles and capabilities.
- Create the agent that you want to protect. See Creating an agent.
- Determine which positions each check must screen. A check runs at one or more of the following positions:
input screens the message of the user before the agent processes it.
output screens the response of the agent. Agent Studio holds the response text until the output checks pass.
tool_call screens the arguments of a tool call before the tool runs.
tool_result screens the result that a tool returns.
- Determine which action each check takes when it finds a match:
- Block stops the request and returns a refusal.
- Mask replaces the matched text.
- Hash replaces the matched text with a keyed hash. This action needs a hash key that the administrator configures.
-
Launch the Cloudera Agent Studio console.
-
In the left navigation pane, click .
The Agents page is displayed.
-
In the list of agents, open the Actions menu of your agent, and then click Edit.
The agent editor opens.
-
In the Files pane, click More actions next to Add, and then click Configure guardrail.
The Guardrails Configuration panel opens with the banner All guardrails are off.
-
Optional: In the Domain section, describe the subject area of the agent and set the reply for blocked requests.
-
In Domain name, enter a short name for the domain.
-
In Domain description, enter a description of the topics that the agent covers.
-
In Blocked reply, enter the text that Agent Studio returns when a guardrail blocks a request.
The default text is Request blocked by guardrails.
The panel pre-fills Domain name and Domain description for the agent.
-
Optional: Route requests by intent.
-
Under Intent routing, turn on Enable intent routing.
The panel shows the collapsed In domain, Meta introspection, and Out of domain sections, and the Classification settings.
-
Expand In domain, and then optionally enter values in the following fields. Enter one item on each line in the first three fields.
- In domain keywords (one per line)
- In domain patterns (one per line)
- In domain utterances (one per line): the default utterance is
Help me with this agent's domain.
- In domain response
-
Expand Meta introspection, and then enter values in the following fields. Enter one item on each line in the first three fields.
- Meta introspection keywords (one per line)
- Meta introspection patterns (one per line)
- Meta introspection utterances (one per line): the default utterance is
What can you do?
- Meta introspection response: this field is required. The default response is
I can help with questions about this agent's domain.
-
Expand Out of domain, and then enter values in the following fields. Enter one item on each line in the first three fields.
- Out of domain keywords (one per line)
- Out of domain patterns (one per line)
- Out of domain utterances (one per line): the default utterance is
Tell me about an unrelated topic.
- Out of domain response: this field is required. The default response is
I can only help with questions about this agent's domain.
-
Under Classification, select Keyword classifier, LLM classifier, or both. Both classifiers are selected by default.
-
In Minimum confidence (0-1), enter a decimal from 0 to 1. The default is
0.6.
-
In Minimum margin (0-1), enter a decimal from 0 to 1. The default is
0.1.
-
In Default intent, select In domain, Meta introspection, or Out of domain. The default is In domain.
-
Optional: Mask personal data.
-
Under PII & sensitive data, turn on Enable PII masking.
The panel adds a check named PII — built-in patterns with the check ID contact-pii. To turn the check off without removing it, turn off the toggle next to its name.
-
Optional: In Check ID, change the identifier of the check.
-
Under Positions, select the positions that the check screens. The
input and output positions are selected by default.
-
In Action, select Block, Mask, or Hash. The default is Mask.
-
Under PII entities, select the types of personal data to detect. The EMAIL entity is selected by default.
- EMAIL detects an email address.
- PHONE detects a phone number.
- SSN detects a social security number.
- CREDIT_CARD detects a credit card number. The number must pass the Luhn check and have 12 to 19 digits.
For a list of builtin regex patterns, see Guardrails.
-
Optional: Filter content by words or patterns.
-
Under Content filters, click Add content filter.
The panel adds a filter named Content filter with the check ID content-filter. To turn the filter off without removing it, turn off the toggle next to its name.
-
Optional: In Check ID, change the identifier of the filter.
-
Under Positions, select the positions that the filter screens. The
input position is selected by default.
-
In Action, select Block, Mask, or Hash. The default is Block.
-
In Content words (one per line), enter the words to match. Enter one word on each line.
-
In Content patterns (one per line), enter the regular expressions to match. Enter one expression on each line.
-
To add another filter, click Add content filter.
-
Optional: Add an advanced check.
While the advanced check form is open, Save is unavailable. Finish adding the check or cancel it before you save the policy.
-
Under Advanced checks, click Add advanced check.
-
In Check ID, enter an identifier for the check. This field is required.
The identifier must contain 1 to 63 lowercase letters, digits, or hyphens, and must start with a letter or digit.
-
In Check type, select one of the following types. The default type is Prompt injection.
- Prompt injection
- Content filter
- PII — built-in patterns
- PII — LLM
- Content safety
- LLM judge
-
Under Positions (select at least one), select the positions that the check screens. The
input position is selected by default.
-
If the Action list is available, select an action. For Prompt injection, the Action list is unavailable because the check supports the block action only.
-
For Prompt injection, optional: In Extra injection patterns (optional), enter additional patterns. Enter one pattern on each line.
-
Click Add check.
To discard the check, click Cancel.
If the form has an error, a message that begins Correct the following before adding this check: lists what to fix. For example, Enter a valid check ID: 1–63 lowercase letters, digits or hyphens.
-
In the header of the Guardrails Configuration panel, click Save.
The guardrails.yaml file appears in the Files pane. Agent Studio rejects a policy that contains invalid YAML, duplicate keys, unknown fields, invalid patterns, duplicate check IDs, or invalid weights. To revert the changes that you made since the last save, click Discard changes.
The guardrail policy is part of the agent. When guardrails are on, Agent Studio applies the policy to the whole agent bundle. End users cannot turn off the policy. When a guardrail blocks a turn, the turn ends with the error code guardrail_triggered, and the agent returns the blocked reply.