AI Guardrails - The Missing Layer Every AI Application Needs
On June 9, 2026, Anthropic launched Claude Fable 5, one of the most capable public AI models ever released. Three days later, it was banned…
AI Guardrails - The Missing Layer Every AI Application Needs
On June 9, 2026, Anthropic launched Claude Fable 5, one of the most capable public AI models ever released. Three days later, it was banned by the US government. This is no longer a story about benchmarks. This is history changing phase.
1. The Wake-Up Call: Claude Fable 5
On June 9, 2026, Anthropic publicly released Claude Fable 5 the public-facing version of their Mythos-class model, excelling at coding, reasoning, and complex agentic tasks. Three days later, the US government issued an export control directive, suspending all access to Fable 5 and Mythos 5 for foreign nationals. Anthropic had to disable both models entirely to comply.
This is the moment the tech industry can no longer afford to be naive.
We used to think of AI as a technology product: whoever builds faster, smarter, cheaper wins. Fable 5 revealed something different. When an AI model is capable enough to interfere with source code, cybersecurity, sensitive data, critical infrastructure, and biological knowledge, it is no longer a “software service” in the traditional sense. It becomes a strategic capability.
And strategic capabilities always attract politics.
The government’s decision can be read through three layers:
- Duty — the state believes protecting national security cannot be fully outsourced to corporations
- Consequence — even if a model delivers enormous productivity, a sufficiently serious risk to infrastructure, defense, or cybersecurity overrides economic benefit
- Power — who gets to define what “safe” means? The AI company, researchers, the market, or the state?
That last question is the hardest one. And it points to a deeper truth: powerful AI cannot be governed by trust alone.
The Jailbreak Claim — and Anthropic’s Rebuttal
Shortly after Fable 5’s release, security researcher “Pliny the Liberator” publicly claimed to have bypassed Fable 5’s safety classifiers using a coordinated, multi-step strategy:
- Unicode & Cyrillic character substitution: evading keyword classifiers at the character level
- Long-context reference tracking: smuggling harmful intent across large conversations
- Academic document framing: embedding harmful queries inside legitimate-looking study guides
- Narrative/fiction framing: masking offensive intent as creative content
He published screenshots allegedly showing the model producing software-exploit code and chemical-synthesis instructions, and even leaked what he claimed was Fable 5’s 120,000-character internal system prompt.
However, Anthropic disputed these claims. According to their response to SecurityWeek, what Pliny demonstrated was not a true jailbreak of Fable 5’s core safety systems. Anthropic explained that:
- A real jailbreak would need to bypass their independent safety classifiers — systems that operate separately from the model itself, meaning even if a user bypasses the model’s conversational refusals, these deeper protections remain intact.
- Upon reviewing the shared examples, Anthropic found that some outputs were not generated by Fable 5 at all, and those that were only contained general information already publicly available — providing no meaningful uplift toward real-world harm.
- What Pliny achieved was convincing the model to continue responding after an initial refusal — a known limitation present in nearly all LLMs, not a bypass of core safeguards.
In short: Pliny bypassed the conversational refusal layer — not the core safety classifiers.
Despite Anthropic’s rebuttal, the US government still issued the export control directive. Whether the jailbreak was “real” or not, the incident exposed a deeper truth that every developer building on LLMs should internalize: model-level safety — no matter how sophisticated — will always be questioned, tested, and potentially circumvented.
This raises a fundamental question: what can we do at the application level to add an independent, verifiable layer of control?
The answer is Guardrails.
2. The Core Problem: LLMs Are Non-Deterministic
Before diving into guardrails, it’s important to understand why they are necessary in the first place.
Large Language Models are fundamentally non-deterministic. Given the same input, they can produce different outputs each time. Techniques like:
- Prompt engineering
- Fine-tuning
- RLHF (Reinforcement Learning from Human Feedback)
- RAG (Retrieval-Augmented Generation)
… have all helped improve reliability. But none of them fully eliminate output variability.
This creates a critical gap when moving from proof-of-concept to production — especially in regulated industries like healthcare, finance, and government, where reliability and compliance are non-negotiable.
Common failure modes in production GenAI applications include:
- Hallucination: Chatbot confidently cites a recipe that doesn’t exist
- Off-topic response: Pizza shop bot explains Ford truck specifications
- PII leakage: User’s name and phone number stored in backend logs
- Competitor mention: Customer-facing bot recommends a competitor by name
3. What Are Guardrails?
Guardrails are secondary checks and validations that ensure the inputs or outputs of an LLM call conform to a predefined set of rules. The core philosophy is simple:
Don’t blindly trust the LLM. Explicitly verify.
3.1. Two Layers of Protection
Guardrails operate at two critical points in your LLM pipeline:

Figure 1: Without guardrails, the prompt flows directly through the LLM pipeline with no validation. With guardrails, an Input Guard intercepts the prompt before it reaches the LLM (checking for PII, proprietary info, jailbreak attempts), and an Output Guard validates the LLM response before it reaches the user (checking for hallucinations, NSFW content, and sensitive topics).
- Input Guard — validates the prompt before it reaches the LLM. Catches jailbreak attempts, PII, and off-topic queries at the source.
- Output Guard — validates the LLM response before it reaches the user. Catches hallucinations, unsafe content, and policy violations.
3.2. Three Types of Guardrail Mechanisms
Under the hood, a guardrail can use one or more of the following mechanisms:

Figure 2: In a production system, all three mechanisms are typically chained into a Combined Guardrail Stack: a rules-based gate catches obvious violations first (fast, cheap), an ML model screens for subtler issues, and a secondary LLM call handles complex semantic verification. A request either passes through to generate output, or is terminated/modulated at any stage.
In practice, the most robust guardrails use a combination of all three.
3.3. Three Key Benefits
- Enforce inviolable constraints — e.g., never leak PII. Guardrails make this an explicit, verifiable guarantee rather than a best-effort promise.
- Measure undesirable behavior — track how often your LLM refuses queries, goes off-topic, or generates unsafe content. Turns a fuzzy problem into measurable metrics.
- Contain cascading errors — critical for agentic and multi-step workflows, where one bad output can corrupt all downstream steps. Guardrails draw a bounding box around what your AI can do.
4. Four Real-World Use Cases
4.1. Hallucination Detection via NLI
The problem: A RAG chatbot confidently generates a recipe that doesn’t exist in the knowledge base.
The solution: Natural Language Inference (NLI) — a technique that checks whether the LLM output is grounded in the retrieved source documents.

Figure 3: The NLI model takes two inputs — a Premise (trusted source document) and a Hypothesis (LLM output sentence) — and classifies their relationship as Entailment (pass ✓), Contradiction (fail ✗), or Neutral (fail ✗).
How it works:
LLM Output
│
▼
Sentence Chunking (NLTK tokenizer)
│
├── Sentence 1 ──→ Find Top-5 Relevant Sources (cosine similarity)
├── Sentence 2 ──→ Find Top-5 Relevant Sources
└── Sentence N ──→ Find Top-5 Relevant Sources
│
▼
NLI Model (HuggingFace)
Premise: Source document
Hypothesis: LLM sentence
│
┌─────────┴─────────┐
│ │
Entailed Contradictory/Neutral
(Pass ✅) (Fail ❌ — Hallucination detected)
Implementation:
from guardrails import Guard, Validator
from sentence_transformers import SentenceTransformer
from transformers import pipeline
import nltk
class HallucinationValidator(Validator):
def __init__(self, sources, entailment_model):
self.embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
self.sources = sources
self.nli_pipeline = pipeline(entailment_model)
def sentence_splitter(self, text):
return nltk.sent_tokenize(text)
def find_relevant_sources(self, sentences):
# Embed sentences + sources, compute cosine similarity
# Return top-5 most relevant sources per sentence
...
def check_entailment(self, sentence, sources) -> bool:
result = self.nli_pipeline({"premise": sources, "hypothesis": sentence})
return result["label"] == "entailment"
def validate(self, value, metadata):
sentences = self.sentence_splitter(value)
relevant_sources = self.find_relevant_sources(sentences)
hallucinated = []
for sentence, sources in zip(sentences, relevant_sources):
if not self.check_entailment(sentence, sources):
hallucinated.append(sentence)
if hallucinated:
return FailResult(error_message=f"Hallucinated sentences: {hallucinated}")
return PassResult()
4.2 Keeping Chatbots On Topic via Zero-Shot Classification
The problem: Users can abuse a chatbot by asking questions completely unrelated to its intended purpose — wasting compute, degrading UX, and potentially exposing your system to unexpected behavior. For example, a customer service bot for a restaurant has no business explaining vehicle specifications.
The solution: Zero-shot topic classification using BART (Meta) — the same NLI architecture, but repurposed for topic detection.

Figure 4: BART takes the input text as the premise and reformulates each candidate label as a hypothesis (“This text contains discussions of: {label}”). The NLI model then scores how likely each label is entailed — producing a likelihood score per topic without any task-specific training data.
How BART zero-shot classification works:
Input text: "The Ford F-150 has better towing capacity..."
Topics to check: ["food", "automobiles", "politics"]
Hypothesis template:
"This sentence contains discussions of the following topics: {topic}"
BART NLI → Likelihood scores per topic:
food: 0.021
automobiles: 0.891 ← banned topic detected!
politics: 0.088
LLM vs. BART Classifier — a critical comparison:

For production, local BART wins decisively.
Implementation:
from transformers import pipeline
classifier = pipeline(
"zero-shot-classification",
model="facebook/bart-large-mnli",
hypothesis_template="This sentence contains discussions of the following topics: {}"
)
def detect_topics(text, topics, threshold=0.5):
result = classifier(text, topics)
return [
topic for topic, score in zip(result["labels"], result["scores"])
if score > threshold
]
class ConstraintTopicValidator(Validator):
def __init__(self, banned_topics, threshold=0.5):
self.banned_topics = banned_topics
self.threshold = threshold
def validate(self, value, metadata):
detected = detect_topics(value, self.banned_topics, self.threshold)
if detected:
return FailResult(error_message=f"Banned topics detected: {detected}")
return PassResult()
4.3. PII Detection & Anonymization via Microsoft Presidio
The problem: Personally Identifiable Information (PII) is any data that can be used to identify a specific individual — names, email addresses, phone numbers, social security numbers, dates of birth, and so on. In GenAI applications, PII leakage can happen in two directions: a user accidentally shares their private data in a prompt (which then gets sent to a third-party LLM provider and stored in backend logs), or the LLM retrieves and surfaces someone else’s sensitive data from the knowledge base in its response. Both carry real legal and financial risk, especially in healthcare, finance, and government contexts.

Figure 5: In the unsafe pattern, raw PII flows directly through the GenAI service to the third-party LLM provider — leaking sensitive data outside your system. In the safe pattern, a PII Filter intercepts and sanitizes the data first, so only clean, anonymized data ever reaches the LLM provider.
The solution: Microsoft Presidio — an open-source tool for PII analysis and anonymization.

Figure 6: A production PII pipeline runs 5 stages in sequence: Regex catches known patterns (SSN, phone formats), NER extracts named entities, Checksum validates format integrity, Context Words boost detection confidence, and finally Anonymization applies masking or redaction — all governed by an organizational policy engine.
Implementation:
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
analyzer = AnalyzerEngine()
anonymizer = AnonymizerEngine()
text = "Can you check orders for Hank Tate? My number is 555-867-5309."
# Step 1: Detect PII entities
results = analyzer.analyze(text=text, language="en",
entities=["PERSON", "PHONE_NUMBER"])
# Output: [PERSON: "Hank Tate", PHONE_NUMBER: "555-867-5309"]
# Step 2: Anonymize
anonymized = anonymizer.anonymize(text=text, analyzer_results=results)
# Output: "Can you check orders for <PERSON>? My number is <PHONE_NUMBER>."
Two layers of PII protection:
- Input Guard: Blocks PII from leaving your system before reaching the LLM
- Output Guard: Redacts PII from LLM responses in real-time streaming
Best practice: Always sanitize your data before ingesting it into the vector database. But accidents happen — the output guard is your safety net.
4.4. Competitor Mention Detection via Cascading Filters
The problem: A customer-facing chatbot, when asked to compare your product to a competitor, responds with a detailed comparison — mentioning the competitor by name.
The solution: A cascading 3-stage filter that handles both exact and fuzzy matches.
Why cascading? A company can be referred to by many names — “JPMorgan”, “JPMC”, “JP Morgan Chase”. Simple exact match can’t catch all variants.

Figure 7: The cascading approach first runs a fast exact match (regex). If no match is found, it extracts named entities via NER (BERT), then computes cosine similarity between entity embeddings and known competitor embeddings. A similarity score above the threshold (e.g. 0.9 > 0.8 for “Cloud-Tech”) triggers a Fail. Only when similarity falls below threshold (e.g. 0.3 < 0.8) does the text Pass.
Implementation:
from transformers import pipeline
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
ner_pipeline = pipeline("ner", model="bert-base-cased")
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
class CompetitorCheckValidator(Validator):
def __init__(self, competitors, threshold=0.85):
self.competitors = [c.lower() for c in competitors]
self.competitor_embeddings = embedding_model.encode(competitors)
self.threshold = threshold
def exact_match(self, text):
return [c for c in self.competitors if c in text.lower()]
def extract_entities(self, text):
results = ner_pipeline(text)
return list(set([r["word"] for r in results
if r["entity"].startswith(("B-", "I-"))]))
def vector_similarity_match(self, entities):
if not entities:
return []
entity_embeddings = embedding_model.encode(entities)
similarities = cosine_similarity(entity_embeddings,
self.competitor_embeddings)
matches = []
for i, entity in enumerate(entities):
if similarities[i].max() > self.threshold:
matches.append(entity)
return matches
def validate(self, value, metadata):
# Stage 1
if self.exact_match(value):
return FailResult(error_message="Competitor exact match detected")
# Stage 2 + 3
entities = self.extract_entities(value)
matches = self.vector_similarity_match(entities)
if matches:
return FailResult(error_message=f"Competitor fuzzy match: {matches}")
return PassResult()
5. Guardrails Hub — Don’t Build Everything From Scratch
All four validators above can also be pulled directly from Guardrails Hub — a community-driven repository of production-ready validators.
Benefits of Hub validators over building your own:
- Support for many more entity types out of the box
- Real-time streaming support
- Server mode — run guardrails as a sidecar service
- Battle-tested in production environments
python
# Install from hub
guardrails hub install hub://guardrails/detect_pii
# Use in your guard
guard = Guard().use(DetectPII(pii_entities=["PERSON", "PHONE_NUMBER"]))
Explore the full catalog at guardrailsai.com/hub.
6. Conclusion: The Non-Negotiable Layer
The Claude Fable 5 incident is a stark reminder that model-level safety alone is not enough. No matter how sophisticated the alignment techniques — RLHF, Constitutional AI, safety classifiers — a determined attacker will find a way through.
But beyond security, there is a deeper engineering truth: GenAI is a non-deterministic programming paradigm. You cannot fully predict what your LLM will output. Every production system that relies on a single layer of trust — the model — is one edge case away from failure.
Guardrails don’t replace model safety. They complement it by adding an explicit, verifiable, application-level layer of control that operates regardless of what the model does.
The general process is straightforward:
1. Identify failure modes specific to your use case
2. Build validators to detect when those failures occur
3. Take corrective action — block, anonymize, redirect, or alert
This is also the philosophy behind Human-in-the-Loop (HITL) design: build systems with audit logs, explicit checkpoints, and the ability to stop. Guardrails slow down your AI agents slightly — but they reduce risk and make every AI decision traceable and transparent. In regulated industries, this is not optional. It is the price of deployment.
The future of AI will not be flat, innocent, or defined only by API pricing pages. It will have borders, licenses, audits, data sovereignty, and quiet negotiations between corporations and governments. The Fable 5 ban is not an anomaly — it is a preview.
Before you hit deploy, ask yourself:
- Who is responsible when something goes wrong?
- Where does the risk live in my pipeline?
- Do I have a way to stop, redirect, or audit my AI’s decisions?
- When the model goes wrong, do I have a way back?
Guardrails are how you answer yes to all of the above.
Start exploring the validators available on Guardrails Hub, build your own, and share them with the community. The tools exist. The only question is whether you use them before or after something goes wrong.
This post is based on the course “Safe and Reliable AI via Guardrails” by DeepLearning.AI in partnership with GuardrailsAI, instructed by Shreya Rajpal (CEO & Co-Founder, GuardrailsAI).
메타데이터
- post_id
- 2c826d8c87dd
- slug
- ai-guardrails-the-missing-layer-every-ai-application-needs-2c826d8c87dd
- url
- https://medium.com/@hoangcongtrong054/ai-guardrails-the-missing-layer-every-ai-application-needs-2c826d8c87dd
- canonical_url
- https://medium.com/@hoangcongtrong054/ai-guardrails-the-missing-layer-every-ai-application-needs-2c826d8c87dd
- author_url
- https://medium.com/@hoangcongtrong054
- status
- ok
- fetched_at
- 2026-06-29 22:44:20