Back to the blog

November 24, 2026 · 10 min read · Security · Governance · Agents

Guardrails: Filters on What Goes In and What Comes Out of the Loop

A policy document does not stop a jailbreak. A guardrail is a technical filter on input and output — PII, toxicity, prompt injection — sitting on the path of the loop, with a block you can explain.

Yassine Aqejjaj · HEAD OF AI · Updated on November 24, 2026

Guardrails are technical filters on what enters a loop and what it is allowed to emit: injection attempts, personal data, toxic or off-policy output. They are not the same thing as governance — policies, approvals and receipts. A rule that nobody enforces on the path is a wish. A filter without a log is a guess.

What is a guardrail, in the narrow technical sense?

I use the word here for something that can actually stop a turn: a check on the inbound prompt or tool result, and a check on the outbound answer or tool call. Typical targets are prompt injection, leakage of personal data, toxic language, and outputs that violate a hard rule you have already written down.

That is a smaller object than “AI governance.” Governance is the policy, the approval, the receipt, the named owner. I have written that piece already. This article is about the filter on the path. If you only have the policy, the loop will still talk. If you only have the filter, you will not know who approved the exception.

A glowing blue diagram on a dark grid: Input passes an In Filter, then a Model, then an Out Filter, leading to Safe Output, with a Blocked path off to the side.
A simple guardrail path: input, an inbound filter, the model, an outbound filter, and a safe output — or a block you can explain.
  1. Input
  2. In filter
  3. Model
  4. Out filter
A guardrail sits on the path: inbound text, the model, outbound text or a tool call — and a block you can explain.

Where should the filter sit on the loop?

On the way in, on the way out, and on the tool call — not only on the final sentence. A jailbreak often arrives as a user prompt. A leak often leaves as an answer. A harmful action often leaves as a tool call that looks polite in the transcript. If you only scan the visible reply, you will miss the call that already went out.

I would also filter tool results before they become observations. A retrieved document can carry personal data or an instruction that tries to hijack the next plan. The observe stage is part of the path. Treating it as trusted text is how a careful input filter gets bypassed.

What should you filter first?

Start with the failures that are cheap to detect and expensive to miss: personal data leaving the system, a call to a tool the agent is not allowed to use, an obvious injection pattern you have already seen. Toxicity and brand-risk language matter, but they are a poor first target if the loop can already book a payment or read a file it should not see.

Write the rule so a block can be explained. “Looks risky” is not a rule. “This field matches a personal identifier and the destination is outside the allow-list” is a rule. When a filter fires, the trace should say which rule, on which span, and whether the loop stopped, retried or asked for a person.

FilterWhat it catchesWhere I put it
Personal dataIdentifiers leaving the system, or arriving in a tool resultInbound prompts, observations, and outbound answers
Forbidden toolA call the agent is not allowed to makeOn the act stage, before the call goes out
Prompt injectionAn instruction that tries to hijack the next planInbound prompts and tool results
Toxicity or off-policy languageOutput that violates a written hard ruleOutbound answers, with a log of the block
Silent rewriteA change nobody can see in the traceI treat this as a failure, not as a feature

How is a guardrail different from a gateway or a governance policy?

A model gateway routes, authenticates, caches and accounts for calls to a model. It can enforce a budget. It does not, by itself, decide whether a particular sentence may leave, or whether a particular tool may be called. I would never let routing stand in for a content filter, or for a decision right.

Governance is the other neighbour. A policy that says “no personal data in prompts” is a decision. A guardrail is the check that makes that decision real on the path. Approvals and receipts belong in the governance article. The filter belongs here. You need both, and they should point at each other in the trace.

What happens when the filter is wrong?

A noisy filter trains people to ignore it. If everyday work is blocked for reasons nobody can read, someone will ask for a bypass, and the bypass will become the product. A silent filter is worse: it drops or rewrites an answer without a trace, and you will debug a “model failure” that was a rule you forgot.

The fix is not to loosen every rule. It is to measure false blocks on a small set, give the owner a way to appeal a single case, and keep the bypass rare, named and logged. A guardrail that cannot be wrong in public will be wrong in private.

How do you test a guardrail without waiting for a real incident?

The same way you test a loop: a fixed set, a judge, a threshold. The set should include injections you have already seen, documents that contain personal data, and clean cases that must still pass. If the filter only ever runs on friendly demos, you will discover its holes in production.

I would also keep a hold-out of new attacks and new documents, so a rule tuned on the training set does not look stronger than it is. A guardrail eval is not a quality eval. It can share a harness. It should not share a score that hides a safety miss behind a fluency gain.

Where does a control plane like TrustRail fit?

Filters on text are necessary and not sufficient when the loop can act. A control plane for agent actions decides whether a tool call is allowed, under which policy, and whether a receipt is written. That is a cousin of the outbound filter, aimed at the act stage rather than at the sentence.

I built TrustRail for that layer. The public demo is at trustrail-mu.vercel.app. I will not invent a figure for how many attacks it catches: I have not published one. The point of mentioning it here is the split of labour. The filter catches what the text should not contain. The control plane catches what the agent should not do. Governance decides who may grant an exception.

What I will not pretend to have measured

I have published access-policy test compliance on a context layer, and I have published quality and coordination figures on platforms that include controls. None of those numbers isolates an input or output filter. Rather than stretch them, I will leave them out.

What I can say from the work is structural. A loop without an inbound check will treat every prompt as trusted. A loop without an outbound check will treat every tool call as a draft. A policy without either will be quoted in a slide and ignored in the trace.

What should you put in place this month?

Pick the two or three failures you cannot afford, write them as rules, and put a check on the inbound prompt, the tool result, and the outbound call. Log every block. Run a short adversarial set before you change a rule. Connect the filter to the approval path so an exception has a name and a receipt.

Then stop. A large catalogue of weak rules is not safer than a short list that actually fires. You can add coverage once the first blocks are understandable. A guardrail that the team can explain will be maintained. A catalogue that only a vendor can read will not.

How should a guardrail work with the loop’s stop rule?

A filter that blocks a turn should also tell the loop what to do next: stop, retry with a safer plan, or ask a person. If the only behaviour is to swallow the output, you will get silent failures and a user who thinks the agent is broken. The stop rule and the filter belong in the same trace.

I would treat a hard safety miss as a stop, not as a creative retry. A retry is for a malformed call or a transient tool error. Mixing the two is how a jailbreak gets a second chance. The harness should make that distinction visible, so a reviewer can see whether the loop respected the block.

What I would tell a team that only has a policy document?

Write the two or three rules that must fire, put them on the path, and log the blocks. Then connect those blocks to the approval path you already described in governance. A policy document is not wasted work — it is unfinished work until a filter can say no, and a person can say yes, with a receipt.

FREQUENTLY ASKED QUESTIONS

Are guardrails the same as AI governance?

No. Governance is the policy, the approval and the receipt. A guardrail is the technical check on the path. You need both. A policy without a filter will not stop a turn. A filter without a policy will not tell you who may grant an exception.

Is a model gateway a guardrail?

Not by itself. A gateway can authenticate, route, cache and cap spend. A guardrail checks the content of a prompt, an observation or an output, and can block a tool call that should not go out. They sit next to each other. They are not the same door.

Where should I start if I have nothing?

Block the obvious leaks and the tools the agent must not call, and log every decision. Add injection and toxicity once those hard stops work. A short list you can explain is safer than a long list that nobody reruns.

What if the filter blocks good work?

Measure false blocks on a fixed set, and give an owner a logged way to appeal a single case. Do not invent a silent bypass. A noisy rule you can see is easier to fix than a quiet rewrite that looks like a model error.

Where can I see a control plane for agent actions?

The public TrustRail demo is at trustrail-mu.vercel.app. It is about allowing or denying an action under a policy, with a receipt — a cousin of the outbound filter, aimed at the act stage. It is not a substitute for input and output text checks.

RESULTS

In + out

filters on the path, not only the reply

3 rules

better than a catalogue you cannot test

1 log

every block named and traceable

THE CODE

TrustRail ↗

KEEP READING

Building Enterprise Agentic Platforms: Lessons from NOVAAI Operating Model: From Experiments to Enterprise AdoptionEvaluating Multi-Agent Systems in ProductionContext Engineering: Beyond Traditional RAGWhat Is an AI Factory? How to Set One Up Inside a Large OrganisationAgentic AI vs RAG vs Workflows: How to ChooseSovereign Generative AI for the Public Sector: Lessons from DILAAI Agent Governance: Policies, Human Approval and Signed ReceiptsMCP in the Enterprise: Connecting Agents to Confluence, Jira and Microsoft 365 SafelyEarned Autonomy: Governing AI Coding Agents Across the SDLCThe AI Agent Mind Map: From Idea to ProductionLangGraph, CrewAI, OpenAI, Google, Microsoft, Claude: which agentic orchestration framework should you choose?Agentic Loops: Plan, Act, Observe, Reflect — Until the Work Is DoneMCP: One Interface, Many Tools — What the Protocol Does and What It Does NotSubagents and Multi-Agent Systems: When to Split the Work, and How to Merge ItAI Gateway: One Control Plane, Many ModelsInference Economics: Tokens, Cache and Model Choice Drive the BillEvals: The Ship-or-No-Ship Test for a Single Agentic LoopObservability: Seeing and Replaying the Loop, Not Just Scoring ItThe Agent Harness: You Own the Loop, the Vendor Ships the Model

Figures come from validated client results and from my role at Devoteam. The projects on GitHub are public betas.