Guardrails are the safety boundaries and validation rules that constrain what an AI agent can do in production. They sit between the model's intent and real-world execution.
Without guardrails, an agent can loop indefinitely, call unauthorized tools, generate harmful content, or take irreversible actions.
Types of guardrails
| Layer | What it controls | Example |
|---|---|---|
| Input | What the agent accepts | Block prompt injection, sanitize user input |
| Reasoning | What the model decides | System prompt constraints, output format rules |
| Tool | What actions execute | Parameter validation, allowlists, rate limits |
| Output | What the agent returns | Content filtering, PII redaction |
| Loop | How long the agent runs | Max iterations, timeout, cost caps |
Guardrails vs. HITL
Guardrails are automated constraints that run without human intervention. Human-in-the-loop adds manual checkpoints for cases automation can't safely handle. Production agents need both.
Implementation approaches
- Schema validation on tool parameters before execution
- Allowlists for permitted tools and actions
- Output classifiers that flag policy violations
- Circuit breakers that halt the loop on repeated failures
- Audit logging of every tool call and decision
Related reading
See Human-in-the-Loop for manual oversight patterns, and Agent Loop for where loop limits apply.