---
title: "Guardrails pattern for AI agents | Agentic Pattern Language"
description: "Screen user input before the agent sees it, and its output and actions before they take effect. Sourced from OpenAI, Anthropic, and Google."
url: https://agenticpatternlanguage.com/patterns/guardrails/
---

20 [Systems of agents](https://agenticpatternlanguage.com/#systems-of-agents)

# Guardrails

Screen user input before the agent sees it, and its output and actions before they take effect.

SW OpenAI, Anthropic, Google, Simon Willison

[How to read this](https://agenticpatternlanguage.com/notation/)

## Builds on

* [Spotlighting](https://agenticpatternlanguage.com/patterns/spotlighting/)

## Alternatives

* [Human approval](https://agenticpatternlanguage.com/patterns/human-approval/)
* [Sandboxing](https://agenticpatternlanguage.com/patterns/sandboxing/)
* [Dual LLM](https://agenticpatternlanguage.com/patterns/dual-llm/)

## The problem

An agent left unchecked can leak data, take harmful actions or say things that damage your brand.

> Uncontrolled agents can pose risks, including executing misaligned or harmful actions, such as data exfiltration, and generating inappropriate content that can impact your brand’s reputation.

Google [Safety and Security for AI Agents](https://google.github.io/adk-docs/safety/)

> Well-designed guardrails help you manage data privacy risks (for example, preventing system prompt leaks) or reputational risks (for example, enforcing brand aligned model behavior).

OpenAI [A practical guide to building agents](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf)

## Therefore

> Guardrails enable you to do checks and validations of user input and agent output.

OpenAI [Guardrails - OpenAI Agents SDK](https://openai.github.io/openai-agents-python/guardrails/)

> Filter user input for known injection patterns before it reaches Claude. You can use an LLM to create a generalized validation screen by providing known jailbreaking language as examples.

Anthropic [Mitigate jailbreaks and prompt injections](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/mitigate-jailbreaks)

## In use

Claude Code

> Auto mode is a new mode for Claude Code that delegates approvals to model-based classifiers—a middle ground between manual review and no guardrails.

Anthropic [How we built Claude Code auto mode: a safer way to skip permissions](https://www.anthropic.com/engineering/claude-code-auto-mode) Mar 25, 2026

Claude (Constitutional Classifiers)

> Our final production-grade system … a linear probe screens all traffic, escalating flagged exchanges to a probe-classifier ensemble for final judgment.

Anthropic [Next-generation Constitutional Classifiers: More efficient protection against universal jailbreaks](https://www.anthropic.com/research/next-generation-constitutional-classifiers) Jan 9, 2026

## Where it breaks

A model that screens for attacks cannot be shown to catch them all, and a check run in parallel may finish after the model starts.

> If you patch a hole with even more AI, you have no way of knowing if your solution is 100% reliable.

SW Simon Willison [You can’t solve AI security problems with more AI](https://simonwillison.net/2022/Sep/17/prompt-injection-more-ai/) Sep 17, 2022

> Blocking execution guarantees that the expensive model does not start; with parallel execution, the expensive model may already have started before the guardrail completes.

OpenAI [Guardrails - OpenAI Agents SDK](https://openai.github.io/openai-agents-python/guardrails/)

## Sources

1. [A practical guide to building agents](https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf) OpenAI
2. [How we built Claude Code auto mode: a safer way to skip permissions](https://www.anthropic.com/engineering/claude-code-auto-mode) John Hughes, Anthropic, Mar 25, 2026
3. [Next-generation Constitutional Classifiers: More efficient protection against universal jailbreaks](https://www.anthropic.com/research/next-generation-constitutional-classifiers) Anthropic, Jan 9, 2026
4. [Guardrails - OpenAI Agents SDK](https://openai.github.io/openai-agents-python/guardrails/) OpenAI
5. [Safety and Security for AI Agents](https://google.github.io/adk-docs/safety/) Google
6. [Mitigate jailbreaks and prompt injections](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/mitigate-jailbreaks) Anthropic
7. [You can’t solve AI security problems with more AI](https://simonwillison.net/2022/Sep/17/prompt-injection-more-ai/) Simon Willison, Sep 17, 2022

Added Nov 14, 2026
