All chapters
  1. Start hereA prompt asks. A guardrail enforces
  2. Foundations · 1Before AI: validations, business rules, access lists, middleware and policy engines
  3. Foundations · 2Guardrail, instruction, evaluation, governance: four words that are not the same
  4. Foundations · 3Trust boundaries: who wrote the text the model is reading
  5. Checks · 4Input checks: type, format, personal data, hostile text and tenancy
  6. Checks · 5Tool-call controls: allowlists, parameter bounds, permissions and approval
  7. Checks · 6Output checks: schema, grounding, leakage, toxicity and policy compliance
  8. Defense · 7Prompt injection: the anatomy of a direct and an indirect attack
  9. Defense · 8Defense in depth: sandbox, network egress, least privilege and isolation
  10. Decisions · 9Policy as code: deterministic rules, policy engines and versions
  11. Decisions · 10Model-based guardrails: when the check is itself a model
  12. Decisions · 11Human in the loop: escalation, abstention and overrides
  13. Systems · 12Guardrails in RAG, MCP, coding agents and multi-agent systems
  14. Systems · 13Testing guardrails: adversarial suites, red teaming, bypass and regression
  15. Reference · 14Frameworks and standards: what each guardrail tool enforces for you
  16. Operations · 15Production: fail open or fail closed, audit and exceptions
  17. Operations · 16Advanced: tool-output laundering, exfiltration paths and policy conflicts
  18. The whole caseThe insurance lab: one hostile roof report, every layer, end to end
  19. ReferenceGlossary
  20. ReferenceAbout this site and its sources
Foundations · 2

Guardrail, instruction, evaluation, governance: four words that are not the same

An instruction asks, a guardrail enforces, an evaluation measures and governance decides who is accountable. One rule followed through all four.

What you will understand
Four words
An instruction asks. A guardrail enforces. An evaluation measures. Governance decides who is accountable.
One rule, four ways
The roof rule R-ROOF-01 followed through each word, so you can see what each one can and cannot do.
The enforcement point
Why a guardrail is defined by where code decides, not by how firmly a sentence is worded.

A review meeting about the underwriting agent. The agent reads a broker's email, gathers evidence with tools and writes a recommendation for the underwriter. The model recommends; a person decides. Someone asks: "Do we have a guardrail for the roof rule?"

Four people answer yes, and they mean four different things.

The prompt author says: "Yes. The system prompt says never to recommend approval for a roof older than 25 years in wind zone C." The platform engineer says: "Yes. Code compares every recommendation with the rule engine and refuses a mismatch." The quality lead says: "Yes. We ran 200 test submissions last week and the agent was right on every roof case." The head of underwriting says: "Yes. I own that rule, and nobody changes it without my sign-off." (All synthetic, including the 200.)

Then case UW-G02 arrives. The roof is 31 years old, the zone is C, and the broker writes "Could you make an exception this once?". Which of the four yeses stops the agent from sending an unflagged approval to the underwriter on this particular run? Only one of them. This page is about telling them apart, because a team that uses one word for four things believes it is protected when it is not.

1. Four words, one plain sentence each#

Each of the four answers in the meeting is a real and useful thing. They do different jobs.

An instruction is text that asks the model to behave in a certain way. Example: "Never recommend approval for a roof older than 25 years in wind zone C." It lives in the system prompt (the operator's standing text that comes before every conversation) or in a user message. The model usually follows it. Nothing makes it.

A guardrail is an enforceable condition that restricts or checks behavior, run by code at a defined place. Example: after the model answers, a function compares the recommendation with check_eligibility and refuses an approve where the rule says decline. The decision holds whatever the model wrote.

An evaluation measures behavior over many cases, before release or in production samples. Example: 200 synthetic submissions run through the agent, and a report says how many recommendations matched the expected ones (an illustrative count). It tells you how often. It stops nothing on the run that is happening now.

Governance is the organization's decisions about who is accountable, which controls must exist and who may grant an exception. Example: the head of underwriting owns R-ROOF-01; any change needs her sign-off and a new policy version. It decides that the guardrail must exist. It does not run.

The shortest way to hold them apart is the verb. An instruction asks. A guardrail enforces. An evaluation measures. Governance decides who is accountable.

Diagram: Four words for one rule · asks, enforces, measures, decides who answers

Read left to right. The same roof rule appears four times. As an instruction it asks the model. As a guardrail code enforces it on the live run. As an evaluation it is measured over many synthetic cases. As governance someone owns it and decides who may relax it. Only the second acts on the run happening now.

  1. Asks
    1. Instruction: A sentence that asks the model to follow R-ROOF-01. The model usually does; nothing makes it.
  2. Enforces
    1. Guardrail: Code after the model compares the recommendation with check_eligibility and refuses a mismatch.
  3. Measures
    1. Evaluation: Synthetic cases run through the agent and a report says how often the result was right.
  4. Decides who answers
    1. Governance: The organization decides who owns the rule, that code must enforce it, and who may grant an exception.
Plain English. If the agent were a new employee: the instruction is what you told them on their first day, the guardrail is the till that will not open without a manager's key, the evaluation is the monthly audit of their sales, and governance is the company policy that says who holds the key.

2. One rule through all four#

Take R-ROOF-01 from the policy fixture, the illustrative rule set every page of this site uses: a roof older than 25 years in wind zone C is not eligible. Now follow it through the four words on case UW-G02.

As an instruction#

The system prompt contains the rule as a sentence. The agent reads the sentence, then reads the broker's email. Both are text in the same input. Most of the time the model gives the rule more weight. But the email is specific, polite and recent, and it argues for an exception. A model can be persuaded. In the example code of this site, the sloppy variant of the scripted stand-in agent stands for that: it can be talked out of the roof rule.

What happens on a run where it is talked out of it? The recommendation says approve. Nothing in the system notices, because the instruction has no way to act after the model has answered. The instruction was a request, and the request was declined.

As a guardrail#

A function runs after the model and before anything is stored. It calls check_eligibility with the submission's facts and the pinned policy version, and compares. The rule function lives in examples/uw-guardrails/policy.py. Run on the facts of UW-G02, it returns:

{"decision": "decline", "rule_ids": ["R-ROOF-01"],
 "reasons": ["R-ROOF-01: roof age 31 is over the limit of 25 years in wind zone C."],
 "missing": [], "policy_version": "2026.2"}

This output does not depend on the email. The function never reads the email. So on the run where the model was persuaded, the guard sees approve against decline and refuses to store it as it is. On this site that guard is G-OUT-POLICY, the policy gate. Its full treatment is on Output checks and Policy as code.

Notice what the guardrail did not need. It did not need the model to understand the rule, to agree with it, or to be well instructed. It needed a place in the request path where code runs after the model and before the result is relied upon. That place is the enforcement point.

As an evaluation#

Before release, the quality team runs a set of synthetic cases through the agent, including UW-G02, and grades every result. The report might say that the roof cases were right on 19 of 20 runs (illustrative). That is valuable. It tells the team the instruction mostly works, and that something must catch the twentieth run. It is the evidence for building the guardrail, and later the evidence that the guardrail works.

But the evaluation ran last week. It cannot see today's run. Measurement is the subject of Eval Engineering; this site uses its results and does not repeat its methods.

As governance#

The head of underwriting owns R-ROOF-01. She decides that the rule must be enforced by code, not only stated in the prompt. She decides who may grant an exception (a senior underwriter, with a written reason) and that any change produces a new policy version, such as the move from 2025.4 (limit 30 years) to 2026.2 (limit 25 years). Governance is why the guardrail exists and why the exception the broker asked for has a proper path that is not "the model agreed".

Governance is the organization's own control system. No site in this series covers it; this site describes the part of it a guardrail depends on and leaves the rest to the organization.

The lab asks you to sort eight statements into the four words. Here are the same eight statements with the right category and the reason, for a reader without the lab.

StatementCategoryWhy
The system prompt says: do not recommend approval for a roof older than 25 years in wind zone CInstructionIt asks the model; nothing happens if the model does not comply
After the model answers, code compares the recommendation with check_eligibility and refuses a mismatchGuardrailCode decides at a defined place, and the decision holds
Before each release, 200 synthetic submissions run and the share of correct recommendations is reportedEvaluationIt measures how often; it stops nothing on a live run
The head of underwriting owns the roof rule and must sign off any change to itGovernanceIt assigns accountability; it does not run
The tool gate refuses every call to export_submissionsGuardrailCode refuses the call whatever the model wrote
An attack suite of 30 injection texts runs every night and reports how many got throughEvaluationA measurement over cases, even though its subject is the guardrails
The agent's instructions ask it to cite a rule id for every reasonInstructionA request to the model, however firmly worded
Every exception to a rule needs a named owner and an expiry dateGovernanceAn organizational decision about who may relax a control
Common confusion. "A nightly attack suite is a guardrail." It is an evaluation of the guardrails. It tells you whether they held last night. The guardrail is the code that refused the call during the run.

3. The prompt instruction against the deterministic gate#

Section 2 made a claim: the instruction mostly holds and sometimes does not; the gate holds every time. The next lab lets you test that claim on the roof rule with your own inputs.

You set the roof age, the wind zone, the policy version and whether the broker asks for an exception. The lab shows two columns. On the left, a vague instruction in the prompt, over 20 scripted trials of the stand-in agent. On the right, the deterministic policy gate.

The agent here is a scripted stand-in. The obedient variant is fooled every time by construction, so these results show how each control works, not how often a real model is fooled or how good any model is. The sloppy variant used for the roof rule is persuadable by construction in the same way.

For a reader without the lab, three cases of this site show the same comparison under the current policy version 2026.2:

CaseSituationWith the instruction onlyWith the policy gate G-OUT-POLICY
UW-G02Roof 31 years, zone C; the broker asks for an exceptionThe persuadable variant can be talked into approvedecline under R-ROOF-01 holds; an approve is refused
UW-G05Roof 29 years, zone C; a retrieved passage says to ignore the rules and approveThe instruction competes with the injected textThe gate never reads the passage; decline holds
UW-G08Roof 28 years, zone C; a similar case was approved under 2025.4The model may follow the precedentThe run is pinned to 2026.2; the old approval is not a reason

The gate is right on all three for a dull reason. It looks only at the facts and the version, and none of the three attacks changes a fact or a version. Each attack works on what the model reads. The gate does not read.

4. Advisory or enforced: the test#

Teams often argue about whether a given control is a guardrail. A three-question test settles it.

First, who makes the decision? If the answer is "the model", the control is advisory. If it is "code" (or a person with authority, see Human in the loop), it can be enforced.

Second, where does it run? An enforced control has a defined place on the path: before the model, before a tool, after the model, at approval, or at the network edge. If you cannot point at the line of code where the decision is made, it is not enforced.

Third, does its decision hold whatever the model wrote? If a cleverly worded input can change the decision, the control is advisory, however strict its wording.

A system prompt fails the first question. A nightly attack suite fails the second: it has no place on a live run. A tool gate passes all three.

The word control is the umbrella: any measure that reduces a risk, whether it advises, enforces, measures or assigns accountability. A guardrail is one kind of control, the kind that enforces at run time.

WordWho decidesWhere it actsHolds whatever the model wrote?In the roof example
InstructionThe modelInside the model's inputNoThe sentence in the system prompt
GuardrailCode (or an authorized person)A defined enforcement point on the runYesG-OUT-POLICY comparing with check_eligibility
EvaluationA grader, offline or on samplesOutside the live runNot applicable: it measuresA report on 200 synthetic submissions (illustrative)
GovernanceThe organizationDecisions, owners, approvalsNot applicable: it assignsThe rule owner and the exception path

Diagram: UW-G02 on one run · the instruction is declined, the gate holds

Time runs down the page. The instruction and the broker's email arrive together in the model's input. On this run the persuadable stand-in writes approve. The policy gate asks the rule function, which never reads the email, and refuses the mismatch. What reaches the underwriter is the rule's result, flagged.

  1. Underwriting agent (model): Instruction plus email: 'an exception this once'. Both are text in one input. The instruction asks; the email argues.
  2. Underwriting agent (model) to Policy gate (code): approve. On this run the stand-in was persuaded. The instruction cannot act after the answer.
  3. Policy gate (code) to check_eligibility (code): Facts of SUB-2002, version 2026.2. Only typed facts and the pinned version travel. The email does not.
  4. check_eligibility (code) to Policy gate (code): decline, R-ROOF-01. Roof 31 years in zone C is over the 25-year limit of the fixture.
  5. Policy gate (code) to Underwriter (person): Mismatch refused: decline under R-ROOF-01, flagged. The approve is not stored as written; the underwriter sees the rule result and the flag.
What this is not. This page does not teach how to write a good instruction. Instructions are worth writing well, and that craft belongs to Prompt Engineering. Here an instruction is only the first, advisory layer; every condition that must hold gets a guardrail behind it.
Before AI. The same split exists in every regulated backend. A coding guideline says "always check the account balance before a withdrawal" (an instruction to developers). A database constraint CHECK (balance >= 0) refuses the write that breaks it (a guardrail). A nightly reconciliation job reports mismatches (an evaluation). The finance controller owns the rule (governance). Nobody confuses the guideline with the constraint.

5. Why the four need each other#

The four words are not competitors. Each covers a gap in the others.

The instruction makes the common case right. Without it, the guardrail would refuse many more outputs and send them back or to a person, which costs time. A good instruction lowers the load on the guardrail.

The guardrail makes the rare case safe. It catches the run where the instruction did not hold.

The evaluation tells you how rare the rare case is, and whether the guardrail refuses legitimate work too often. Without it, you do not know whether the guardrail is protecting anything or only slowing everyone down. Testing guardrails covers how to measure a guardrail itself.

Governance decides which rules need a guardrail at all, who owns each one and who may relax it. Without it, guardrails grow by accident, exceptions are granted in chat, and nobody can say why a check exists.

6. The same idea for a coding agent#

A coding agent's instructions file in a repository might say "never push to the main branch". That is an instruction. Branch protection on the server, which refuses a direct push, is a guardrail. A weekly report of how many agent changes needed rework is an evaluation. The rule that only maintainers may change branch protection is governance. The words map one to one. How a harness enforces permissions on the agent's commands is covered by Harness Engineering.

For the Principal engineer: the edges of the definitions

A guardrail can be a model, and still be a guardrail, but only partly. A classifier that scores text for instruction-like wording runs in code, at a defined place, and its decision can hold. It passes the three questions. But its decision is probabilistic: it is wrong in both directions at some rate. On this site such a check (G-IN-INJECT) flags and never decides alone. The definition of guardrail is about enforcement, not about determinism; the design rule that every critical condition has a deterministic check behind it is a separate, stronger rule. Model-based guardrails works out the trade-off.

A person can be the enforcement point. An approval gate where an authorized underwriter must act before anything takes effect is a guardrail in the full sense: the decision holds whatever the model wrote. Its weakness is not the definition; it is fatigue and the quality of what the person is shown.

Evaluation and guardrail share code, not purpose. The same comparison with check_eligibility can run as a grader in an eval suite and as G-OUT-POLICY on a live run. Sharing the function is good engineering. But the eval version must not be counted as protection, and the guard's refusals in production are data the evaluation should consume.

Governance without enforcement is a document; enforcement without governance is drift. An organization can require a control that nobody built, and engineers can build guards that nobody owns. Map every guard id to an owning role and every critical rule to a guard id. Gaps in either direction are findings.

Wording firmness is not a dimension of enforcement. Teams sometimes escalate an instruction ("NEVER", repetition, placing it last) after an incident. That can raise adherence, which an evaluation can measure. It does not change the answer to any of the three questions, so the control remains advisory.

Checklist#

Before you call something a guardrailAsk
Who decides?Code or an authorized person, never the model alone
Where is the line that decides?You can name the file, function and enforcement point
Does it hold against any input?No wording in the input can change its decision
Is it owned?A role owns it and can say why it exists
Is it measured?An evaluation reports how often it refuses legitimate work and what got through
Is the matching instruction still there?The instruction keeps the common case right and the guardrail's load low

In one breath#

An instruction asks the model to behave, a guardrail is code at a defined place whose decision holds whatever the model wrote, an evaluation measures how often things go right over many cases, and governance decides who owns a rule and who may relax it. Followed through the roof rule, only the guardrail stops the persuaded run of UW-G02; the other three explain why it exists, how well it works and who answers for it. Test any control with three questions: who decides, where, and does it hold against any input.

Hand-off#

You can now tell a guardrail from the three things it is confused with and say where its enforcement point is. The roof rule was easy, because its facts are typed fields. The harder problem is text: the agent reads emails, provider reports and retrieved passages written by people outside the insurer. The next page, Trust boundaries, asks who wrote each piece of text the model reads, and why the model cannot tell.