Guardrails

Guardrails are optional policy checks that Agent Studio can apply to text entering and leaving an agent, as well as to agent tool calls.

Guardrails in Agent Studio protect your confidential information by blocking unauthorized data transmission to Large Language Models (LLMs) during workflow runs.

An agent author defines a guardrail policy in the guardrails.yaml file at the root of the agent bundle.

The policy applies to the entire agent bundle, including work delegated to sub-agents. Sub-agent configuration files cannot override the policy. You can edit guardrails in the Agent Editor interface. For instructions on configuring guardrails for an agent, see Configuring guardrails for an agent.

When Agent Studio validates the bundle, it rejects a policy that contains invalid YAML, duplicate keys, unknown fields, invalid patterns, duplicate check identifiers (IDs), or invalid weights.

End users cannot disable a policy through a run request, a resume request, a permission mode setting, or human approval.

Guardrail checks

By default, language-model checks use the model configured for the agent session.

The following table describes the available guardrail check types:

Table 1. Agent Studio guardrail check types
Check type Purpose Actions you can set
injection Detects prompt-injection patterns. You can add extra_patterns. block
content_filter Matches words or patterns that you list. mask, hash, block
pii_regex Detects personal data by pattern: email address (EMAIL), phone number (PHONE), social security number (SSN), and credit card number (CREDIT_CARD, which must pass the Luhn check and have 12 to 19 digits). mask, hash, block
pii_llm Uses a language model to detect personal data such as PERSON, ADDRESS, and custom entity types. mask, hash, block
content_safety Screens for unsafe content by categories and a threshold. You can define custom categories. block
llm_judge Uses a language model to score the text against criteria (each with a name, a description, and a weight; the weights must total 100) and blocks the text when it crosses a threshold. Runs at exactly one position. An output judge runs only on the final turn. block

Failure behavior

Agent Studio treats a check as failed and blocks the request under any of the following conditions:

  • A language-model check returns a missing or invalid reply.
  • The required model provider API key is absent.
  • A check times out.
  • A check exceeds the text limit.

When a guardrail blocks a turn, the turn ends with the guardrail_triggered error code. When guardrails are required but unavailable, the turn ends with the guardrails_unavailable error code.