StoryboardAI Engineering

Guardrails

Checks placed before and after a model call, in code or small models, that stop certain messages going in and certain replies coming out.

What are guardrails?

A guardrail is a check that sits outside the main model. Input guardrails look at a message before the model sees it: is it abuse, is it off the subject, is it an attempt to rewrite the rules? Output guardrails look at a reply before the person sees it: does it contain private data, a link it should not, or a claim nothing supports?

Some checks are plain code, such as a pattern for card numbers. Others are a small, fast model asked one narrow question. Both are cheaper and quicker than the main model, and both can be wrong in two directions: letting something through, or blocking something innocent.

A sentence in the system prompt is not a guardrail. It is a request to the same model that is being tricked. A guardrail is something the model cannot talk its way past, because the model is not the one deciding.

Guardrails add delay and cost, and they only catch what they were built to look for. They are one layer among several, alongside narrow permissions and human approval.

Guards stand outside the model, on both sides.Step 1: A message arrives. Step 2: Checks on the way in. Step 3: The main model replies. Step 4: Checks on the way out.1A message arrives2Checks on the wayin3The main modelreplies4Checks on the wayout
Guards stand outside the model, on both sides.

Why do guardrails matter?

A model will try to help with whatever it is given, and can be talked into things. A product needs limits that do not depend on the model agreeing with them. Guardrails are checks placed outside the model, on what goes in and what comes out, so that certain things do not happen whatever the model was persuaded of.

How do guardrails work?

  1. Before the main model sees a message, plain rules check it: length, rate, known attacks.
  2. A small model sorts it into a kind: a real question, off the subject, an attempt to change the rules, abuse.
  3. Stopped messages get a fixed reply, written by a person.
  4. After the main model replies, code scans the reply for things that must never leave.
  5. A small model checks that every claim is supported. A reply that fails is rewritten once, then handed to a person.

When should you use guardrails?

Use it when

  • Anyone can type anything into your product
  • A wrong or unsafe reply would cause real harm
  • People may try to use the product for something else at your expense

Think twice when

  • The risk is an action, not words. Use narrow permissions and approval for that
  • Delay matters so much that no check can be afforded. Then limit what the product can do instead

Where do guardrails sit in a real system?

Guardrails sit in the harness on both sides of the main model call. They are separate from the model on purpose: different code, and often a different, smaller model.

What goes wrong with guardrails?

  • Calling a line in the system prompt a guardrail.
  • Letting the main model write the refusal, where it can still be steered.
  • Measuring only what got through, and never what was wrongly blocked.

What does guardrails look like in practice?

In a week of 20,000 messages, guards stopped 212 bad ones, let 9 through, and wrongly stopped 31 innocent ones, including a question about carrying a camping knife. Both kinds of error are counted, and every wrong stop is read.

Watch it happen

These stories show guardrails at work, one step at a time.