What Are AI Guardrails?

AI guardrails are the checks and limits built around a language model application to keep it within its intended scope. They inspect what goes into the model, validate what comes out, and restrict what the system is allowed to do. Guardrails exist because the model itself cannot be fully trusted to follow instructions every time: they make sure that when it does get something wrong, the mistake is caught or contained.

The word covers a wide range of mechanisms, from a regular expression that removes card numbers to a permission system that stops an agent from deleting records. The most effective guardrails are usually ordinary software, not more AI.

Types of Guardrails

Input guardrails run before the model sees a request:

  • topic and scope checks (a banking assistant declines medical questions),
  • detection of prompt injection and jailbreak attempts,
  • removal or masking of personal data that the model does not need,
  • size and rate limits.

Output guardrails run before a response reaches the user or another system:

  • schema validation for structured output (correct fields, types and allowed values),
  • grounding checks that the answer is supported by the retrieved sources,
  • filters for unsafe, offensive or off-brand content,
  • checks for leaked secrets, internal identifiers or other users’ data,
  • link and reference validation, so the answer cannot point to a page that does not exist.

Action guardrails apply when the model can call tools or change data, which is the case for every AI agent:

  • least privilege: the agent gets only the tools and permissions the task needs, never more than the user it acts for,
  • read-only access by default,
  • allow-lists of operations, amounts and destinations,
  • human approval before anything that moves money, changes records or settings, or sends messages outside the organisation,
  • spending and step limits, so a looping agent stops.

Why Prompt Instructions Are Not Enough

Telling the model “never reveal customer data” in the system prompt is useful but not a guardrail on its own. Instructions can be overridden by crafted input or simply not followed. OWASP’s guidance for LLM applications makes the same point: alongside constraining behaviour in the system prompt, it recommends validating output formats with deterministic code, filtering inputs and outputs, enforcing least privilege in application code, and requiring human approval for high-risk actions (OWASP LLM01:2025).

Classifier models (a second, smaller model that labels input or output as safe or unsafe) are a useful layer, especially for content safety. They are probabilistic too, so they belong alongside deterministic checks, not instead of them.

Common Failure Modes

  • Guardrails only on the chat box. Documents, emails and web pages the system reads are also input, and they need the same scrutiny.
  • Over-blocking. Filters so strict that legitimate questions are refused. Users then route around the system.
  • No testing. Guardrails that were never attacked during testing tend to fail on the first real attempt. They need their own evaluation set, including adversarial cases.
  • Silent failure. A blocked response with no log entry hides both attacks and false positives.
  • Permissions in the prompt. “Only access records for this user” written as an instruction, instead of enforced by the database query.

Guardrails are a core part of AI security and AI governance. They reduce the impact of AI hallucination and prompt injection, rely on structured outputs for validation, and work together with human-in-the-loop review. Their effectiveness is measured with LLM evaluation. NIST’s Generative AI Profile, a companion to its AI Risk Management Framework, is a widely used reference for the risks that guardrails address (NIST AI 600-1).

Guardrails in Practice

Guardrails are designed from the actions backwards: list everything the system can change, then decide for each action whether it runs freely, needs the user to confirm it, or needs a person to approve it. Access is read-only unless writing is needed, and an agent never has more permissions than its user, because a filter on the model’s output can be talked around while a missing database permission cannot. Model-based filters for content safety and topic scope sit on top of those hard limits, each with its own test cases, and blocked events are logged and reviewed for false positives as well as real attacks. Learn more about AI security solutions development.

Back to Glossary

Let's talk about your project

We'll help you harness AI and ML technologies to create innovative software solutions

File requirements: pdf, doc, docx, rtf, ppt, pptx — max 15 MB

No file selected