Dismiss

New here? Start the Builder path.

Home · Agents · 09 · Guardrails

Concept card · Agents

Guardrails

What this gets you. Check what goes into and comes out of your agent, and stop or reroute a run when a check fails.

A guardrail is an automatic check at a fixed point in your agent's run. When the check fails, the run gets a fixed reply, a retry, a rerouted handoff, or a stop.

Last checked 2026-10-21 8 min

Search for Guardrails

What changed

Oct 26: OWASP sources now point to the 2026 list, where some entries have new numbers.

Earlier updates

Oct 21: First card. A check can stop or reroute a run before a bad reply or a bad tool call lands. Sources include Anthropic, Google, the Model Context Protocol, OpenAI, OWASP and NIST.

Skip to Practice if you already check tool arguments next to each tool and fail closed when a check is down.

From Prompt injection: where can untrusted text enter a run?

Show the answer

In the user's message, and also in documents and tool results the agent reads later. What these checks defend against: Prompt injection.

1 What it is

A guardrail is an automatic check at a fixed point in your agent's run: on the input, around a tool call, on the reply, or on the run as a whole. When the check fails, it changes what happens next. The run gets a fixed reply, a retry, a rerouted handoff, or a stop.

The steps, in order.

  1. 1 · InputCheck the request before the main AI model runs.
  2. 2 · Before a toolCheck the arguments right next to the tool that will act.
  3. 3 · After a toolCheck what came back before the model reads it.
  4. 4 · OutputCheck the reply before it leaves: it cites a source, it has no secrets, and it is safe to display.
  5. 5 · Run limitsCap steps, failures, calls per minute and wait time. Your stop rules from Agent loop are one of these limits.
  6. 6 · On failDecide in advance whether you reply, retry, reroute or stop. If the check itself can't run, pause rather than pass.

Example: made up to show the idea.

The same support assistant, with checks in five places.

Where Check On fail
Input Asks for a password or secret A fixed reply: how to reset your own password
Before create_ticket The account id matches the signed-in customer An error goes back to the loop to fix; after 2 failures, stop
After search_docs Text marked untrusted, such as the pasted note Kept as data, labelled, not treated as policy
Output The reply cites a doc, and no account number appears Redact, or swap in "I don't know" and hand off.
Run 4 tool calls, 1 ticket per conversation, a time limit Stop and hand the transcript to the support person.

One output check you've seen: Citation & grounding check.

Who gets the handoff: Permissions.

A customer asks: "Open a ticket for account 4471." That isn't the signed-in account, so the check before create_ticket fails. The loop gets "account doesn't match", asks the customer to confirm, and no ticket is filed. Later the output checker times out. The reply is held and handed to a person instead of being sent unchecked.

If the check is about, then where

If the check is about Put it On fail
what the user asked before the main AI model a fixed reply, or hand to a person
a tool's arguments right before that tool runs return the error to fix, or stop
what a tool returned right after that tool label or drop the text, then continue
the reply before it leaves redact, or swap in a safe reply
how long or how often on the whole run stop and hand off
a check that can't run anywhere pause, don't pass

Beyond the schema: does this value make sense for this user? See Tool calling.

2 Why it matters

Show why it matters

Cost

A check before the main AI model can stop an off-task request before the expensive call runs.

Quality

Checking a tool's values catches the wrong account before a ticket lands on it.

3 How to apply · try today

Pick one tool your agent calls that changes something. Write one check for its arguments, put it right before the call, and write what happens when it fails, and when the check itself is down.

Common mistake

Checking only the first message. In a run with several steps or agents, the input check runs once. Text that arrives later from tools doesn't meet it. Put a check next to the tool.

Self-check

A check makes sure create_ticket gets the signed-in customer's account id. Where does it go?

Self-check

The output check times out. What's the safer default?

Self-check

Which job is a guardrail's, rather than a permission's?

Next: CI checks are guardrails on a code change, and a person still merges. Working with a coding agent.

Want the why? Understand it · 6 min, optional

Questions

Can an AI model be the check?
Yes. A second, cheap and fast model can screen inputs or replies. Treat its verdict as one signal, and test it like any other check.
Is a guardrail the same as an eval?
No. An eval tests your agent on fixed examples before release. A guardrail runs on every real request.

Next card: Failure modes →