LLM guardrails
Guardrails are automated checks placed around a large language model (LLM) application to keep its inputs, outputs and actions within set rules. They run outside the model, so they still work when the model is wrong or has been manipulated. A guardrail can block, rewrite, mask or send a request for human approval.
How it works
Input guardrails screen prompts for prompt injection, banned topics and personal data.
Output guardrails validate the format, mask secrets and catch unsupported claims.
Action guardrails limit which tools an agent may call, and require approval for writes.
For example, an output check can match AWS access key IDs, which are 20 characters starting with AKIA, and replace them with [REDACTED] before a response leaves the service.
Why it matters in production
Models are probabilistic, so a rule written in the prompt is followed most of the time and ignored some of the time. Guardrails enforce the rule in code you can test and log. Each check adds latency and can block good answers, so teams measure false positives the same way they measure errors.
See also
On the One2N blog
Further reading
![Pipeline of an LLM app with three guardrails. A prompt passes an input check for injection and personal data, then reaches the LLM. The answer passes an output check before becoming the response; for example, an AWS key, AKIA plus 16 characters, is replaced with [REDACTED]. A red note says the output check blocks good answers too. A tool call from the LLM passes an action check, where writes need approval.](https://framerusercontent.com/images/hTiJ77hVoTjDJ7VCyHmDX97Su5w.png?width=1200&height=1200)
Putting this into practice?