What guardrails are
What it is
Guardrails are checks that run around the model call, not inside it:
- Input guardrails inspect the request before the model sees it: is it in scope, is it an attack, does it contain data that should not be sent?
- Output guardrails inspect the answer before the user sees it: is it safe, on topic, free of leaked data, in the right format, supported by the sources?
A check can block, rewrite, or flag for review.
Why it matters
Instructions in a prompt are requests the model usually follows, not rules it cannot break.
- Anything that must hold every time needs to be enforced outside the model, by something that does not depend on the model's cooperation. Guardrails are that layer.
- They are also where a system decides, in code, what it refuses to do.
In the real world: A bank's assistant passes every answer through a check for account numbers and investment advice before display; the model's instructions say the same, and the check catches the times it slips.
Visual example
GuardrailsThe model sits in the middle. Nothing reaches it, or leaves it, unchecked.
Treating the system prompt as the guardrail. 'Never discuss competitors' in a prompt will hold most of the time and fail under pressure. If it matters, check the output.