esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Are Guardrails?

What AI guardrails are, where they sit around a model, what they cannot stop, and how to explain them simply for your AI interview.

In short

Guardrails are checks placed around an AI model or agent: on what goes in, what comes out, and which actions it may take. They sit outside the model, so teams can change them without retraining. They reduce risk, but text checks can be beaten by rephrasing, so teams layer and test them.

11 min readBeginnerVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A guardrail is a check placed around an AI model. One check screens what goes in, like a customer's message or a web page the model reads. Another checks what comes out, like a reply that leaks a card number. A third checks actions, so a payout over a set limit waits for a person. The checks run outside the model, as code or as checker models, so a team can change them without retraining. They reduce risk, but a check that reads text can be beaten by rephrasing, so I layer them and test them against people who try to get around them.

What are guardrails, in plain words?

A guardrail is a check placed around an AI model, so that it stays on the road. The model still writes the answer or asks for the action. The guardrail decides what is let in, what comes out and what the model may do.

Think of a hospital pharmacy. A doctor can write almost any prescription, but the pharmacist checks the dose, the allergy list and the patient record before anything is handed over. The doctor is the model. The pharmacist's checks are the guardrails.

A real AI case: a clinic's notes assistant drafts a letter to a patient. Before the letter goes out, a check looks for a drug the patient is allergic to, and blocks the letter if it finds one.

Key words

Guardrail
A check or limit around an AI model, written as code or a separate check, outside the model itself.
Input check
A check on text before the model reads it.
Output check
A check on the model's reply before the user sees it.
Tool check
A check on an action the model asks for, such as a payment, before it runs.
Agent
An AI app that asks for tools, such as a refund or an email function, and runs them to finish a task.

What are the three kinds of guardrail?

  • Input

    What goes in

    Screens what the user types and what the model fetches, such as a web page, before the model reads it.

  • Output

    What comes out

    Checks the reply for card numbers, banned topics or a made-up policy, before the customer sees it.

  • Action

    What the model may do

    Checks each tool call, such as a refund or an email, against a rule. Big or risky actions wait for a person.

Where guardrails sit around a model

What comes in

Customer's question

typed into the support chat

Retrieved web page

may hide an order to the model

Input check

screens text before the model reads it

Model

drafts an answer or asks for a tool

Replies and actions

Output check

blocks card numbers and banned topics

Tool check

payouts over a limit wait for a person

Safe reply or action

only what the checks let through

  1. 1The customer's question passes the input check first.
  2. 2A web page the model reads gets the same check, since it is input too.
  3. 3Only screened text reaches the model.
  4. 4The draft reply is checked before the customer sees it.
  5. 5Any action the model asks for is checked before it runs.
  6. 6A reply that passes the check goes out.
  7. 7An allowed action runs. A large payout waits for a person.
Checks sit before the model, after it, and on every action it asks for. Only input that passes reaches the model, and only replies and actions that pass reach the customer.

NVIDIA's open-source NeMo Guardrails toolkit describes the same places in its docs. It can check user inputs, retrieved content, tool calls and model outputs. The model itself can act as a checker, a separate safety model can do the same job, and plain Python code can handle the rest.

  • “Guardrails (or rails for short) are a specific way of controlling the output of an LLM, such as not talking about topics considered harmful, following a predefined dialogue path, using a particular language style, and more.”

    NeMo Guardrails paper, 2023

The 2023 paper defined guardrails as a way of controlling the output of an LLM. It also described a fact-checking rail for retrieval augmented generation. Today's docs list four places to check: inputs, retrieved content, tool calls and outputs.

How do guardrails differ from training the model?

Some safety comes from training. The model learns during training to refuse some requests. The NeMo paper says there are several ways to do this, with guardrails embedded in the model.

Runtime guardrails are different. They are separate checks that run around the model while the app is live, so the team can add, change or remove one without touching the model. The paper says these rails are independent of the LLM underneath. That is why I treat them as an extra layer on top of training.

Take the claims assistant. If the payout gate moves from $2,000 to $1,500, a team changes one number in its code and tests it the same day. Changing how the model itself was trained is a much bigger job: a new training run, then a full round of safety tests.

Can guardrails stop every attack?

No. A semantic filter, a check that judges the meaning of text, can be beaten. The OWASP Gen AI Security Project says so about those checks:

  • “Semantic filters are evadable by rephrasing or encoding”

    OWASP Gen AI Security Project, LLM01:2026

So teams stack several checks, keep a person on risky actions, and test with people who try to beat them. Anthropic's guidance on jailbreaks lists the same kind of layers: input screening, hardened system prompts and safe handling of untrusted tool content.

Tip

Asked whether guardrails solve prompt injection, say no. They lower the odds and limit the damage. That is the honest answer.

How would you guard a claims assistant?

An insurer's claims assistant answers customers and drafts replies for claims handlers. It can also ask the payments tool to approve a payout. Three guardrails sit around it, and a fourth step keeps them honest.

  1. 1

    Screen the input

    A message that tries to override the rules, such as asking the bot to ignore its instructions, is caught by the input check where that check can spot it, before the model reads it. Who may see which claim is a permission in the database, not a text check.

  2. 2

    Check the reply

    Before a draft leaves, a check removes card numbers and stops medical or legal advice. It is blunt, so it also blocks harmless admin lines that mention a medical diagnosis, and an honest customer waits for a human for no reason.

  3. 3

    Gate the payout

    The model may ask for a payout. Anything over $2,000 waits for a claims handler, because a wrong payout costs real money.

  4. 4

    Log and test

    Every blocked reply goes into a test set, so the next version of the checks catches the same trick.

Every check has a cost. Each one adds a little delay per call, and a blunt check wrongly blocks some honest customers. So I log each block, review the false alarms every week and tune the rules, rather than guessing.

Here is the reply check in plain Python. There is no real model in it: the draft is a fixed string, and the check reads that text the way a real check reads the model's output.

Python
# A simplified output guardrail for a claims assistant.
import re

CARD = re.compile(r"\b\d(?:[ -]?\d){12,15}\b")
BANNED = ["medical diagnosis", "legal advice"]

def output_guardrail(reply):
    if any(topic in reply.lower() for topic in BANNED):
        return "I can't help with that here. A claims handler will call you."
    return CARD.sub("[card number removed]", reply)

draft = "Your refund goes to card 4111 1111 1111 1111 by Friday."
print(output_guardrail(draft))
print(output_guardrail("Your claim needs a medical diagnosis review."))
print(output_guardrail("Your claim is approved for $420."))

Output

Your refund goes to card [card number removed] by Friday.
I can't help with that here. A claims handler will call you.
Your claim is approved for $420.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: a check around a model on what goes in, what comes out and what it may do.
  • The three places: input, output and actions.
  • Checks outside the model, as code or checker models, so teams change rules without retraining.
  • Guardrails reduce risk. Text checks can be beaten, so layer and test them.
  • A worked case with real limits, such as a payout gate.
  • Testing against people who try to get around the checks.

Common traps

  • Trap"Guardrails are the same as the model's safety training."

    BetterTraining builds some safety in. In interviews, guardrails usually means the runtime checks you add and change around the model.

  • Trap"Once guardrails are on, the app is safe."

    BetterThey lower the risk. Test them, and keep a person on big or risky actions.

  • Trap"A guardrail is just a longer system prompt."

    BetterA prompt is a request the model may ignore. A guardrail is a check, often code, on what the model produced.

Can you spot the guardrail?

Spot the input check

Your claims bot screens text before the model reads it. Which snippet is that check?

Quick check

A claims bot asks the payments tool to pay $9,000 on a claim approved for $900. Which check would have caught it?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q201What is prompt injection?12 min
  2. Q205Input vs output guardrails?11 min
  3. Q206Name the OWASP LLM Top 10 (2026).10 min
  4. Q209How do you build defence in depth against injection?13 min
  5. Q210Why can't a system prompt alone stop attacks?10 min

Last updated on 26 November 2026

Building an AI app that needs guardrails?

I design and build AI products and agents, the screens and the system behind them, including the checks around the model. Book a short call and say what your app must never do.