# Agent guardrails

A guardrail is a check that runs inline on an agent's input, output, or tool call, and can block
or change it before it takes effect. It might stop a refund over a limit, strip a secret from a
response, or refuse a prompt that tries to override the agent's instructions.

It exists because some failures cost too much to find later. An eval or a grader measures many
runs after they happened and gives you a rate. A guardrail acts on one request while it happens
and stops that one action.

A guardrail can be a rule in code, a small classifier, or a model call that judges the content.
It runs at a fixed point: on the prompt before the model sees it, on a tool call before it
executes, or on the response before the user sees it. Checks on tool calls matter most for an
agent that takes actions, because a bad tool call has an effect even when the final answer looks
fine. When a guardrail fires, the run has to do something next: stop, retry, return a fallback,
or ask a human.

Every guardrail adds latency, and every guardrail can be wrong in both directions. A strict one
blocks good requests, and a model-based one can miss an attack phrased in a way it didn't expect.
Guardrails stop known bad actions; they don't tell you that quality dropped. A run that a
guardrail blocked can also look like a success from the outside, unless the block is recorded
where someone will see it.

## Questions answered under this concept

- [Can a guardrail stop prompt injection?](https://tessary.ai/answers/agent-guardrails/can-a-guardrail-stop-prompt-injection)

---

Source: https://tessary.ai/answers/agent-guardrails
All concepts: https://tessary.ai/answers
From Tessary, agent reliability for AI agents in production: https://tessary.ai
