Skip to content
AgenticAIWiki
  1. Learn
  2. Part 12
  3. 64. Guardrails in depth
  4. 64.11

Lesson 64.11 · 11 of 11 · 6 min read · Reviewed 24 Nov 2026

Guardrail frameworks compared

By the end, you can

  • Tell apart the main kinds of guardrail framework.
  • Pick tools for each layer instead of one tool for everything.

You can build every guardrailGuardrail: A control that keeps an AI system within safe and allowed behaviour, such as input checks, tool limits or output filters. in this chapter by hand, and for small systems that is often right. As checks multiply, teams reach for frameworks. They are not interchangeable: each kind solves a different part of the problem.

The main kinds

Kind What it does Layers it covers Examples
Rail and dialogue frameworks Wrap the model call; you declare input, output and topical rails in config, and it runs the checks around each turn Input, output, topic (64.9) NVIDIA NeMo Guardrails
Validator libraries Run a chain of validators on model output (schema, regex, PII, toxicity) and decide what to do on failure: re-ask, fix, filter or raise Output, structure (64.3) Guardrails AI
Safety classifier models A model trained to label a prompt or a response against a list of harm categories Input, output, moderation (64.6) Llama Guard, ShieldGemma
PII and secret tools Detect and redact personal data and credentials Input, output, logs (64.10) Microsoft Presidio
Managed cloud services Hosted filters for content, topics, PII and grounding, configured in a console Input, output Amazon Bedrock Guardrails, Azure AI Content Safety

A general model with a strict schema (64.8) is a sixth option, and often the most flexible: it can apply your own written policy rather than a fixed taxonomy.

What none of them do for you

  • Enforce who may do what. Refund limits, data access by the signed-in user and approval gates belong in your tools and policy layer (64.4, 64.5). Frameworks screen text; they do not know your business rules.
  • Make an injected agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. safe. They catch many injection attempts, not all (65.2). Least privilegeLeast privilege: Giving each component only the access it needs for its task, and no more. and sandboxes still matter.
  • Decide your policy. A safety taxonomy is someone else’s list. Your product may need stricter or looser lines.

A worked choice

A team runs a public insurance-quote assistant with a tool that books callbacks.

Need Choice Why
Stay on insurance topics Topical rail in a rail framework, or a small model classifier Declared scope, logged per turn
No harmful content in or out A safety classifier model Trained categories, cheap to run
No personal data in logs A PII tool before logging Typed placeholders
Quote JSON must be valid A validator library, or structured outputs Re-ask on failure
Callback booking limits Their own code Business rules

Five needs, three or four tools, plus their own code. That is normal.

How to evaluate one

Run it against your own guardrail test sets (64.7) before you commit:

  • LatencyLatency: The time from sending a request until you get the response, or until the first token arrives when streaming. added per turn, at p50 and p95. Several stacked checks can double response time; run independent ones in parallel.
  • False blocks on normal traffic and edge cases.
  • Bypasses on your attack set.
  • Fit: can you express your policy, see why something was blocked, and version the config with your code?
  • Data path: where does the text go? A hosted service is one more place your users’ data travels.

Common mistakes

  • Adopting one framework and assuming every layer is covered.
  • Leaving the defaults on without testing them on your traffic.
  • Wrapping every call in every check, then wondering why the assistant got slow.

Key points

  • Guardrail tools fall into a few kinds: rail and dialogue frameworks, validator libraries, safety classifier models, PII tools and managed cloud services.
  • Each kind covers some layers well and others not at all; most systems combine two or three.
  • Whatever you choose, permissions and policy for actions still live in your own code.
  • Judge a framework on your own test sets: latency added, false blocks and bypasses.
Hands-on labOn your own machine

Trial a guardrail framework on your tests

Run one open-source guardrail tool against your own small test set and record whether it fits.

You will have: A one-page decision record: the tool, the layer it covers, latency added, false blocks and bypasses on your set, and what it does not cover.

Steps

  1. Pick one tool for one layer, for example Presidio for PII, NeMo Guardrails for topical rails, or Guardrails AI for output validation.
  2. Create a fresh Python virtual environment and install it following its official docs; keep any model API key in an environment variable.
  3. Write 20 test inputs: 10 normal, 5 edge cases and 5 that should be caught. Use only fake data.
  4. Run the tool over all 20, timing each call, and count false blocks and misses.
  5. Fill in the decision record, including which layers still need your own code.

Done when

  • The record shows p50 latency, false blocks out of 15 and misses out of 5.
  • It names at least one layer, such as action limits, that the tool does not cover.

Docs: Microsoft Presidio documentation · NeMo Guardrails (NVIDIA, GitHub) · Guardrails AI (GitHub)

Quick checkA team adopts a safety classifier model to screen chat input and output. Next quarter the agent gains a tool that issues refunds. Which gap does the classifier leave?
How sure are you?
Pick an answer and how sure you are

Finished the chapter? Take the chapter check.