Lesson 169 · 2 min

Guardrails on the way in

Input guardrails check what users send before the model sees it, catching private data, abuse and tricks early.

Anyone can type anything into a public chat box. Some messages contain things the system should never pass on, like full card numbers. Some are attempts to make the bot break its rules, often called jailbreaks.

An input guardrail is a check that runs first. Simple ones use rules: block messages over a certain length, hide anything that looks like a phone or ID number. Smarter ones use a small classifier model that labels the message as fine, off-topic, abusive or a likely trick.

When a check fires, the app can block the message, remove the risky part, ask the user to rephrase, or hand the chat to a person. A bank bot might reply "Please do not share your card number here" and blank it out.

Guardrails make mistakes both ways. Too strict and they block normal customers, too loose and tricks slip through. Teams test them with real examples, keep a log of what was blocked, and adjust over time.

Do it now

Design a front desk for a bot

  1. 1. Imagine a help bot for a small shop or school.
  2. 2. List five messages it should not pass straight to the model, using the prompt below for ideas.
  3. 3. For each, decide: block, clean up, ask again, or send to a person.
I am designing input checks for a customer help bot for [TYPE OF BUSINESS]. Suggest eight risky messages users might send, from harmless mistakes to deliberate tricks, and the best response for each.

Quick check

A customer pastes their full card number into a help bot. What should a good input guardrail do?

A customer pastes their full card number into a help bot. What should a good input guardrail do?

More on this

Words from this lesson

Guardrails
Rules and filters around an AI system that block harmful, off-topic or unsafe requests and answers.
Jailbreak
A trick prompt designed to get an AI to ignore its safety rules and do something it normally refuses.
Prompt injection
Hidden instructions planted in a web page, email or file that try to hijack an AI reading it.
Classifier
A model that sorts things into groups, such as spam or not spam, or which plant is in a photo.
Data privacy
Keeping personal or confidential information under control, including deciding what you type into AI tools and where it is stored.