Open Agent School · Public worked example

Guardrails: meaning and example

Welcome! Take one idea with you today.

A guardrail is a check placed before or after a model step that detects unwanted input or output and can block, rewrite, or escalate it. Most guards are classifiers or rules that estimate risk, so they make mistakes in both directions. A guard is not authorization (deciding whether this user may perform this action) and not sandboxing (limiting what an approved action can touch).

Picture it: An invented neighborhood tool library runs a chat kiosk that answers questions and can unlock lending lockers. Ten synthetic requests arrive: five harmless questions, two unsafe-advice requests, and three polite requests to unlock a locker that belongs to another member. Decide which layer should stop each kind of problem.

What is easy to mix up?

Guards estimate risk from text and will miss some cases. Permission is a fact about the user and the resource, so check it deterministically on the server, and sandbox tools so even approved actions have limited reach.

Teaching example by Open Agent School. Source: OpenAI Agents SDK - Guardrails (input, output, and tool guardrails).