# 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.

AI and LLM interview question Q204, Guardrails and AI safety. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-are-guardrails

## Say it in 30 seconds

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.

## Say it in 2 minutes

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 leaves the counter. An AI guardrail plays the pharmacist's part around a language model. The model drafts the answer or asks for an action, and the guardrail decides what gets through.

There are three places to check. Input checks look at what comes in, such as a customer's message or a web page the model reads. Output checks look at the reply before the customer sees it, for example a card number or an off-topic answer. Tool checks look at an action the model asks for, like a payout, and can hold it for a person if it is over a limit.

The checks run as ordinary code or as separate checker models, outside the model that drafts the answer. So a team can change a rule on Monday without retraining anything. That is the main difference from safety training, which is built into the model.

Guardrails lower the risk. They do not remove it. Text checks can be beaten by rephrasing or encoding, so I stack several checks, keep a person on risky actions, and test with people who try to break them. If someone asks whether guardrails solve prompt injection, my answer is no, and I say what they do limit.

## 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.

- **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.

*Diagram, Where guardrails sit around a model: 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.*
1. The customer's question passes the input check first.
2. A web page the model reads gets the same check, since it is input too.
3. Only screened text reaches the model.
4. The draft reply is checked before the customer sees it.
5. Any action the model asks for is checked before it runs.
6. A reply that passes the check goes out.
7. An allowed action runs. A large payout waits for a person.

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. **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. **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. **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. **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:

```text
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." Better: Training 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." Better: They lower the risk. Test them, and keep a person on big or risky actions.
- Trap: "A guardrail is just a longer system prompt." Better: A 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?

A. reply = redact_cards(model.generate(prompt))
B. if is_blocked_topic(user_msg): return refuse_politely()
C. if human_approved: send_payout(claim_id)
D. print(model.generate(prompt))

**Answer:** B. It runs on what the customer typed, before the model is called. The first runs after the model, the third is an action gate, and the last has no check at all.

**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?

A. An output check that looks for card numbers
B. A tool check that compares the payout with the approved claim amount
C. An input check that blocks messages over 500 words
D. A stronger system prompt that says to never overpay

**Answer:** B. The two amounts are numbers your code already holds, so a tool check can compare them before the payout runs. The card check and the length limit look at the wrong thing, and a prompt is only a request.

## Can you answer these from memory?

**Flash cards**

- **What is a guardrail?** A check around an AI model, on inputs, outputs or actions. Often code.
- **Where do the checks sit?** Before the model (input), after it (output), and on every action it asks for.
- **Guardrail or training?** Training is built in. Guardrails are separate checks you can change at runtime.
- **Can guardrails stop every attack?** No. Text checks can be beaten by rephrasing. Layer them and test them.
- **What does a payout gate do?** Holds any big or risky action until a person approves it.
- **Name an open-source toolkit.** NVIDIA NeMo Guardrails, which checks inputs, retrieved content, tool calls and outputs.

## Likely follow-up questions

- Q201 What is prompt injection? https://designervenkat.online/interview/ai/what-is-prompt-injection
- Q205 Input vs output guardrails? https://designervenkat.online/interview/ai/input-vs-output-guardrails
- Q206 Name the OWASP LLM Top 10 (2026). https://designervenkat.online/interview/ai/name-the-owasp-llm-top-10-2026
- Q209 How do you build defence in depth against injection? https://designervenkat.online/interview/ai/defence-in-depth-against-prompt-injection
- Q210 Why can't a system prompt alone stop attacks? https://designervenkat.online/interview/ai/why-cant-a-system-prompt-alone-stop-attacks
