041 · Gates
Rules that gate an agent’s turn, checked before it runs and after it answers; guardrails that watch every step of it (spec_041_gates)
| Status | Done in v0.7.1 (the owner’s request, 2026-10-17): rules GT-01–GT-11, guardrails GT-20–GT-29. |
| Source | pkg/engine/gates/gates.go, pkg/engine/frontmatter/frontmatter.go, pkg/engine/rules.go, pkg/engine/turn.go, pkg/engine/memory/memory.go (splitRule), pkg/engine/tools/checkpoint.go (LatestTurnDiff), pkg/service/server/rules.go, apps/desktop/web/src/studio/RulesPane.tsx, apps/desktop/web/src/studio/RulesOrGuardrails.tsx, apps/desktop/web/src/studio/ruleForm.ts, pkg/engine/gates/guardrails.go, pkg/engine/guardrails.go, pkg/engine/runtime/guard.go, pkg/redact/pii.go, pkg/service/server/guardrails.go, apps/desktop/web/src/studio/GuardrailsPane.tsx, apps/desktop/web/src/studio/guardrailForm.ts |
| Tests | pkg/engine/gates/gates_test.go, pkg/engine/frontmatter/frontmatter_test.go, pkg/engine/rules_test.go, pkg/engine/memory/memory_more_test.go (TestGateRulesAreNotInstructions), pkg/service/server/rules_test.go, apps/desktop/web/src/studio/ruleForm.test.ts, pkg/engine/gates/guardrails_test.go, pkg/engine/guardrails_test.go, pkg/redact/pii_test.go, pkg/service/server/guardrails_test.go, apps/desktop/web/src/studio/guardrailForm.test.ts |
| Depends on | spec_012_memory (rule files), spec_040_studio |
A team’s expectations of its agents (“never touch production”, “say how the change was tested”) are more dependable checked than hoped for. A rule says one such thing in plain English; a fast model judges it on the prompt before the agent runs, or on the answer and the turn’s changes before the turn ends; and the rule says what a failure does.
- GT-01 A rule file (
*.mdin the rule folders,.blitz/rules,.agents/rules,.claude/rulesand the global one; MEM-07) with front matterwhen: before_agentorwhen: after_agentis a gate: not an instruction (the memory loader skips it), judged around the turn. Other fields:action(block,warnorrevise;warnwhen unset),order(gates run by order, then name),agents(the agents whose turns it gates; none means every agent),description. Its body is the rule. A rule withoutwhenis an instruction rule, unchanged (MEM-07). An unknownwhenoraction, or an empty gate, is the rule’s problem, and it’s skipped (gates.Parse). - GT-02 The judge (
gates.Judge) asks the suggestions model (else auto mode’s, else the workspace’s) whether the subject passes the one rule, with a brief to fail only when the rule is clearly broken (a rule that doesn’t apply passes), and reads its JSON verdict (passorfail, a reason saying what would make it pass). Secrets in the subject are redacted first. - GT-03 Before the agent: once the prompt is accepted (after the
prompt_submithooks), each before-agent gate offered to the active agent judges it, in order. A failing block rule refuses the prompt (*api.BlockedError, “The rule … stopped this prompt: …”), nothing recorded, the agent not run; warn says so in the conversation once the prompt is recorded; revise gives the agent the reason with the prompt (<rules-hook-context>). Side questions aren’t judged. - GT-04 After the agent: once the turn’s passes are done (an approved plan carried out,
stophooks and a goal), each after-agent gate offered to the active agent judges the answer (12 KiB) and the diff of the files the latest pass changed (Checkpoints.LatestTurnDiff, 12 KiB), in order. A failing revise rule sends the agent back with the reasons ("(rules) …" in the transcript,session.KindRule), and the rules judge again, twice at most; then “Rules still fail after 2 revisions”. block marks the answer as failing the rule (an error notice); warn a notice. A plan that wasn’t carried out isn’t judged. - GT-05 A rule the judge can’t judge (no model, an answer that isn’t a verdict) says so (“The rule … couldn’t be checked”) and lets the turn go on.
- GT-06 Every verdict goes to the audit log (
audit.KindRule: the rule, pass, warn, revise, block or unjudged, and the reason). - GT-07
WorkspaceService.ListRulesreturns the workspace’s rules: gates in the order they run, then instruction rules; each with whether it’s editable (in.agents/rules).SaveRulewrites.agents/rules/<name>.mdfrom the form, renaming when the name changes, keeping the front matter’s other fields (frontmatter.Edit); an instruction rule keeps no gate fields, a gate nopaths; problems (a bad name, when or action, an empty rule, a taken name) come back with nothing written.DeleteRule(RULE_NOT_FOUND),ReorderRules(orders 10, 20, 30… in the order given) andTryRule(a sample prompt or answer judged against the rule as written; a judge that fails is aproblem). - GT-08 Studio › Rules (
RulesPane): three lists, Before the agent and After the agent (each in the order its rules run, numbered, with the action and the agents; dragged, or moved with ↑ ↓, to reorder) and Instructions (always, or for the files named); a rule elsewhere than.agents/rulesis listed with its path and opens read-only. + in the title bar (the page’s only one) starts a rule; a new gate goes last in the list its when puts it in. A rule’s form slides in over the list as an agent’s does: name, what it’s for, when (before, after, or an instruction), the action with what it does then, the agents it applies to (or an instruction’s files), the rule with Redraft (DraftManifestkindrule), and for a gate Try it (a sample, Check, the verdict). Back, Cancel and Save; unsaved changes are asked about. - GT-08a 2026-11-05 (scan N26-desktop-4#12: a rule whose
whenwas misspelt was listed under Instructions as “Always”, its problem hidden, and saving it rewrote the gate as an instruction rule). A rule with a problem that isn’t a gate before or after the agent is listed under Need fixing, with its problem, not under Instructions; a rule’s form shows its file’s problem at the top. The form keeps awhenoractionit doesn’t offer as written, so saving shows the service’s problem again instead of turning the gate into an instruction rule. - GT-09 Each list row is one button that opens the rule beside its own buttons (↑ ↓), never a button inside a button, so each control has its own name.
- GT-11 Rules or guardrails: Studio › Rules and Studio › Guardrails both have an (i) beside the page’s title (
GatesTitle) that shows the same side-by-side comparison under it, hidden at first since vertical space is dear (RulesOrGuardrails: what each is for, when it runs, what it checks, what a failure does, an example; the page shown marked “this page”) and a button to the other: rules check the work against the team’s expectations, at the turn’s edges (the prompt before, the answer and changes after), and can send the work back; guardrails are for safety and limits (instructions hidden in fetched pages or files, secrets in answers, spending, risky commands) and watch every step, built in or the user’s own, blocking, redacting or warning, never revising. A line under it says when the other is the one to use (“About safety rather than quality? It’s a guardrail.”). A rule’s form says the same in a line (a gate: “if it’s about safety rather than quality, make it a guardrail”; an instruction rule: it isn’t checked). - GT-10
pkg/engine/frontmatteredits Markdown front matter for Studio’s forms (rules, skills): fields set, or removed when empty, every other field kept in its order.
- GT-20 A guardrail is
.agents/guardrails/<name>.md(or~/.blitz/guardrails/<name>.md, for every workspace; a workspace’s file wins over a global one of the same name), with front matterstage(input: the prompt;tool_result: what a tool returns, before the agent reads it;output: the agent’s answer;action: each tool call, before it runs),action(block,warnorredact; what the stage allows),agents(none: every agent),tools(fortool_resultandaction; none: every tool, or for prompt injection the tools that bring in outside content:web_fetch,web_search,browserand MCP tools),description,enabled(falseswitches it off, its settings kept), and eitherbuiltin: <id>or a body: the user’s own check in plain English. An unknown stage, action or built-in, or a custom guardrail with no body, is its problem, and it’s skipped (gates.ParseGuardrail). Guardrails are listed built-ins first, then by stage and name. - GT-20 2026-11-05 (scan N26-engine-top-1#8: a custom guardrail with a problem was skipped without a word in the turn, and
stage: Actionoraction: Blockwas enough to cause one). A custom guardrail whose file has a problem still checks nothing, but each turn says so, as an error notice once the prompt is recorded: “🛡 The guardrail no-drop isn’t running: stage "actions": … (.agents/guardrails/no-drop.md). Fix it in Studio’s Guardrails.”builtin,stageandactionare read in any case. - GT-20 2026-11-05 (scan N26-engine-top-1#7: the judge saw only the first 12 KiB, and the injection patterns the first 256 KiB of a tool’s result, so what came after reached the agent or the file unjudged). A custom guardrail judges all of what it checks: content over 12 KiB in parts of 12 KiB (each overlapping the last by 1 KiB, the first that fails deciding), up to 8 parts (about 88 KiB); longer content can’t be judged, so a guardrail that blocks refuses it and one that warns says so. The injection patterns read all of a tool’s result, and the judge confirming a match sees the 12 KiB around it.
- GT-20 2026-11-05 (scan N26-engine-top-1#31: a custom
outputguardrail judged the whole answer after it had streamed, and the app keeps streamed text over the final one, so a withheld answer had already been read). While a customoutputguardrail that blocks is on, an answer isn’t streamed: it shows once it’s judged (withheld, or as it is). One that warns lets it stream; the secrets guardrail still masks each piece. - GT-20 2026-11-05 (scan N26-safety-enterprise#6, #7: a misspelt key was dropped without a word, so
allowed_domain:left every domain allowed and a gate writtenWhen:became an instruction rule gating nothing;action: Blockwas a problem that skipped the check). A guardrail’s front matter with a key Blitz doesn’t read (at the top: its settings, a limit’s settings, and the catalog’slock,groupsand aname; underlimits:: the five limits) has that as its problem (a built-in then runs with its defaults). A rule withoutwhen:that has a gate’s key (When,wen,action,order) has that as its problem.when,stage,actionandbuiltinare read in any case. - GT-20 2026-11-05 (scan N26-safety-enterprise#26: a guardrail or rule file, or a folder of them, that couldn’t be read was left out without a word). One that can’t be read is listed with that as its problem (“couldn’t read it: …”, or “couldn’t read the folder: …”), so Studio shows it; a built-in’s then runs with its defaults. A folder that isn’t there has none, as before.
- GT-20 2026-11-05 (scan N26-apps-other spec gaps: a guardrail file with a problem showed only in Studio).
blitz doctorreports each guardrail file with a problem under guardrails (a warning naming the file and the problem), reading the same folders the workspace does (engine.GuardrailDirs). - GT-21 Three built-ins (
gates.Builtins), on by default: without a file, each runs with its defaults (gates.BuiltinDefault). Its file (named after it, so it’s versioned with the project) changes its settings, or switches it off withenabled: false; deleting the file puts it back to its defaults. The built-ins: prompt injection (prompt_injection, tool results,warnorblock; patterns for text aimed at the agent,judge: trueto have the judge confirm a match first), secrets and personal data (secrets, answers,redact,warnorblock; the redactor’s credential patterns, and withpii: trueemail addresses, phone numbers, Luhn-valid card numbers and social security numbers,redact.PII) and limits (limits, actions,block;max_cost_usd,max_turns,max_files_changed,allowed_domains,commands; without a file it refusesgates.DefaultCommands: force pushes,rm -rfof/or~). - GT-21 2026-11-05 (scan N26-safety-enterprise#2: a hand-written
limits.mdthat was a custom guardrail took the built-in’s place, and its ceilings and refused commands went without a word). A file named after a built-in (limits.md,secrets.md,prompt_injection.md) whosebuiltin:isn’t that built-in has that as its problem (“limits.md is the built-in limits guardrail’s file: add builtin: limits, or rename it”), and the built-in runs with its defaults;catalog.Checkrefuses such a file, so a catalog can’t ship one. - GT-21 2026-11-05 (scan N26-safety-enterprise, spec gaps: this item’s prompt_injection actions read “warn or block”). prompt_injection’s actions are redact (the default), warn and block (GT-31).
- GT-22 Limits: a turn’s model calls and spending are capped at the guardrail’s
max_turnsandmax_cost_usd(the lower of it and the turn’s own). Before a tool runs, a URL in its arguments offallowed_domains(a domain allows its subdomains), a shell command matching acommandsglob (*for anything, slashes too,?one character, against the whole command), or a write once the turn has changedmax_files_changedfiles is refused with the reason ("🛡 The guardrail limits stopped this: …"). - GT-22 2026-11-05 (scan N26-engine-top-1#6: only web_fetch and the browser’s navigate were held to
allowed_domains; a browser script, a click off the site, and a workflow’s api_call, a2a_call or OAuth token URL weren’t, and the tool-result guardrails never read a call step’s result).allowed_domainsholds: web_fetch and the browser’s navigate (refused before they run); the browser’sscriptwhile any are set (a script can reach any site: refused); any other browser action whose page ends off them (a click, a form, back: what it found is withheld); and a workflow’s api_call (and its OAuth2 token URL) and a2a_call (and each host its card names), refused before the request. MCP tools’ arguments aren’t read for URLs: an MCP server reaches what it reaches, and the server’s own settings hold it. The tool-result guardrails (the injection guardrail, customtool_resultones) read what a workflow’s mcp_call, api_call and a2a_call steps bring back before the next step does, as they read an agent’s web results; one that withholds it fails the step. - GT-23 Prompt injection, on what a checked tool returns: warn gives the agent the result with a caution that it’s content, not instructions (
guardrailin the result), and says so in the chat; block withholds the result (the agent is told it was withheld and not to follow it) and says so. - GT-24 Secrets in the answer, as it streams and in full: redact masks them ("🛡 … masked secrets or personal data in the answer"), block withholds the text, warn says the answer shows what looks like one. Each guardrail’s notice comes once a turn.
- GT-24b 2026-11-05 (scan N26-followups#1: the engine checked each streamed piece of the answer alone, so a key split across pieces was masked in none of them, and the app and the CLI showed it). The engine holds a streamed answer back as the gateway does (
guardrails.Hold, EN-23): the word still arriving and the 160 characters before it (or the longest secret the workspace knows by value), and a private key until it’s whole, per agent’s stream, then checks what’s settled whole (the secrets the engine expanded, then the guardrails) and sends it. The held end is checked when the answer ends and goes to the front ends as its last piece (runtime.HeldTextKeyon the final response), so what’s shown is the final answer; the final answer is still checked whole. A blocking secrets guardrail stops the stream at the secret. A short answer so shows only once it’s complete. - GT-24a 2026-11-05 (scan N26-engine-top-2#10, #11: a workflow’s parallel steps in one session took each other’s guardrail state away, so notices repeated; an
@server:urimention, andread_mcp_resource, brought an MCP server’s text in past the tool-result guardrails). Turns running at once in a session share one set of guardrails, read when the first starts and let go when the last ends, so each notice comes once for them all.read_mcp_resourcecounts as outside content, asmcp_calldoes, and an@server:urimention’s text goes through the same tool-result guardrails before it joins the prompt: injected instructions redacted (or a warning first, or the text withheld, as the guardrail’s action says). - GT-25 Custom guardrails are judged (
gates.JudgeGuardrail, the rules’ judge with a safety brief):inputon the prompt before the turn (after the input built-ins, before the before-agent rules: GT-03),actionon the tool and its arguments,tool_resulton the result,outputon the whole answer. A failing block refuses the prompt or the call, withholds the result, or withholds the answer, with the reason; warn says so. A custom guardrail that can’t be checked (no model, no verdict) refuses what it guards when it blocks, unlike a rule; when it warns, it says it couldn’t check. - GT-25 2026-11-05 (scan N26-safety-enterprise#32:
pkg/guardrails, the service’s side, let a warning check that couldn’t be judged pass without a finding, and sent the injection judge the tool’s result unmasked). There too, a custom guardrail that can’t be judged doesn’t pass: a blocking one refuses, a warning one records awarnfinding saying it couldn’t be judged and lets the content through; the injection guardrail’s judge gets the result with its secrets masked, as the custom guardrails’ judge does. - GT-26 The engine calls the guardrails through
runtime.Guard(WithGuard):ToolCallbefore a tool runs,ToolResultafter,Outputon the model’s text; a sub-agent’s calls are guarded by its parent’s turn’s guardrails. Every decision goes to the audit log (audit.KindGuardrail). - GT-27
WorkspaceService.ListGuardrailsreturns the built-ins (each as it runs: its file, or its defaults with no path;offwhen switched off) and the workspace’s own guardrails.SaveGuardrailwrites.agents/guardrails/<name>.mdfrom the form (a built-in under its id, edited in place when it’s there,enabled: falsewhen it’s off; renaming when a custom one’s name changes; other front matter kept, GT-10), problems coming back with nothing written.DeleteGuardrail(a built-in’s file: back to its defaults;GUARDRAIL_NOT_FOUND) andTryGuardrail(a sample prompt, result, answer or action checked as the guardrail is written: the patterns for the built-ins, the judge for custom ones). - GT-28 Studio › Guardrails (
GuardrailsPane): Built in, on unless switched off, each with what it watches, its action, a switch (off writesenabled: falsein its file, keeping its settings; on removes it) and its settings; and Your own (+ in the title bar adds one). A guardrail’s form slides in over the list (GT-08’s layout): a built-in’s switch beside its title, its settings (the action; personal data too; confirm with a model; the limits) and the agents it guards, and Reset to defaults (asked first) once it has a file; a custom one’s name, what it’s for, what it checks, the action with what it does then, its tools, agents and what to catch, with Draft or Redraft (DraftManifestkindguardrail); Try it with a sample (not for limits). Back, Cancel and Save, unsaved changes asked about. - GT-28a 2026-11-05 (scan N26-engine-top-2#5: a job’s, a workflow step’s or an eval’s turn got the limits, input guardrails, rules and
\skillmentions of whichever agent was active in the window). A turn’s limits guardrail, input guardrails, before- and after-agent rules and\skillmentions are those offered to the agent the turn runs as: a job’sagent, a workflow step’s (or its job’s), an eval’s, else the active agent, as its tool checks already were. - GT-29 The engine’s notices and the page’s text are in every locale (
guardrail.*,desktop.guardrails.*). - GT-30 2026-10-26 (the owner: “built in guardrails should be of A quality”).
limits’ default commands (gates.DefaultCommands) refuse a force push (git push* --force,--force *,-f,-f *,+*:--force-with-leaseand--force-if-includespass) and recursive deletes of/,~and~/,mkfs*andddonto/dev/sd*,/dev/disk*and/dev/nvme*.CommandDeniedmatches each glob against the whole line and against each command in it (split at;,&&,||,|and new lines;sudo,env,command,execandVAR=valuebefore it dropped), anrmasrm -rf <path>(-r,-f) once per path whatever its flags’ order or spelling,$HOMEand${HOME}as~, quotes off and a trailing/*as the folder. Each built-in records apassonce per turn when it checked something and found nothing (its catches each time), so the dashboard sees it running (spec_044_health HL-19);gates.Describesays how a built-in runs (where, its patterns or limits, its action and the others it has), which the dashboard’s judge reads. - GT-30 2026-11-05 (scan N26-safety-enterprise#3:
git push -uf,git -C . push -fandsudo -u root rm -rf ~passed, though the guide says they’re refused).CommandDeniedalso reads the commands in$(…), backticks andsh -c "…"(bash,zsh,dash,ksh;-lctoo); dropssudo,env,nice,nohup,timeandxargswith their options (xargssince 2026-11-21:… | xargs -0 rm -rf ~passed) (and an option’s argument:sudo -u root,env -u NAME,nice -n 10); reads a git command without git’s own options (-C dir,-c key=value,--git-dir=…,--no-pager), and a push’s bundled short flags one each (-ufas-u -f). - GT-31 2026-10-26 (the owner: prompt_injection still graded C, limits B). prompt_injection redacts by default (
Redact, withWarnandBlock): each matching phrase is taken out of every string in the tool’s result (gates.RedactInjection, the engine’sredactInjection) and replaced bygates.InjectionNote, the rest kept, with a note to the agent; and confirms a match with the judge by default (judgeabsent is true;judge: falseacts on patterns alone; a judge that can’t answer lets the match act). Its patterns take a role or mode change (not “you are now ready”), “from now on, you will…”, keeping something from the user, sending keys, credentials or.envto an address, and instructions in an HTML comment. limits stops a turn at 200 model calls or $10 (DefaultMaxTurns,DefaultMaxCostUSD) unless its file sets them (0: none). Itscommandsmay holddefaults(DefaultsEntry,ExpandCommands): the default list as this version has it; a file withoutcommandskeeps the defaults,commands: []has none. Saving writes only what differs from the defaults (limitsFields,judge: falsealone), and Studio’s form starts from them (defaults, 200, 10; the injection judge on), so a file follows new defaults instead of keeping a copy. - GT-31a 2026-11-05 (scan N26-desktop-4#1: Studio’s limits form saved a cleared or mistyped ceiling as 0, no ceiling, and showed a file’s 0 as an empty field). In Studio’s limits form an empty Most spent or Most model calls is the default: it’s sent as 200 or $10, which
limitsFieldsleaves out, so the file follows the default. No limit (or 0 typed) is the explicit choice and is saved as 0, and a file’s 0 shows as No limit. A value that isn’t a number at or above 0 (a whole one for calls and files) is shown under its field and the form doesn’t save. An empty Commands keeps Blitz’s own list (the API can’t tell an empty list from none, N26 desktop-4#3); its hint says to writecommands: []in the file to refuse none. - GT-32 2026-11-05 (the owner hit “maximum turns reached (200 model calls)” with no hint where it came from; the guide’s example put
max_turnsat the top of the file, where it isn’t read). A turn the limits guardrail stopped says which guardrail set the limit, how to allow more, and, in a conversation, how to carry on (Workspace.limitSource): “maximum turns reached (200 model calls): the guardrail limits sets this by default; to allow more a turn, set max_turns under limits: in .agents/guardrails/limits.md (0: no limit). Send “continue” to carry on where it stopped.”, or the file that sets it; the same formax_cost_usd. A job’s run leaves out “continue” (nobody is there to send it). The 200 stays: the owner keeps it as a safeguard, and a long coding turn reaches it, so the message says how to go on. The error is stillErrMaxTurns/ErrCostLimit(errors.Is), so exit codes andMAX_TURNS/COST_LIMITare unchanged. A limits file with one of its settings at the top of the front matter instead of underlimits:has that as its problem (misplacedLimits). A built-in whose file has a problem runs with its defaults, as without a file (gates.Active,Guardrail.For): before, a mistake inlimits.mdtook away its ceilings and refused commands too. The organization’s policy switching a built-in off still does. - GT-32 2026-11-05 (scan N26-engine-top-1#3, #18: only a job’s run left out “continue”, so eval cases, skill scenarios, the scheduled reflection and a workflow job’s steps told nobody to send it; and a broken
limits.mdread as if there were no file). “continue” is said only where someone can answer (tools.Attended): not in any unattended turn (a job’s run and its workflow’s steps, an eval’s case, a skill’s scenario, the reflection) or a background task. Whenlimits.mdhas a problem and its defaults set the limit, the hint says so: “the guardrail limits runs with its defaults, which set this, because .agents/guardrails/limits.md has a problem: …. Fix it there to change max_turns under limits: (0: no limit).” - GT-32 2026-11-05 (scan N26-engine-top-1#17: the limits guardrail’s other refusals named neither the setting nor its file). A call it refuses for a domain, a command or one file too many says which setting did and where: “… (max_files_changed under limits: in .agents/guardrails/limits.md)”, or, for its defaults, “(by default; set commands under limits: in .agents/guardrails/limits.md to change it)”.
- GT-32 2026-11-05 (scan N26-engine-top-2#1, #7: the hint said “to allow more a turn” while
max_turnscounted per run of the turn; a job stopped at its own limit or the jobs’ default got no hint).max_turnsnow counts a whole turn (spec_017 SES-19a), so “a turn” is right. A limit no guardrail set carries its own hint (limitHints): a job’s run names its WORKER.md, the jobs’ default or their cap (Settings › Library › Jobs; spec_023 WK-43b); an eval’s case or skill scenario says its limit is fixed; the scheduled reflection’s cost namesmax_cost_usdunder[harness]. A guardrail’s hint wins when the guardrail set the limit; in a workflow job, a step stopped by the run’s own limit gets the job’s.
- GT-40 Built 2026-11-15 (the owner: guardrails “are missing features like before/after deterministic and threshold”; blitz-enterprise library plan R2). A guardrail’s
stagemay be named for where it sits around a model call or a tool:before_model(input),after_model(output),before_tool(action),after_tool(tool_result); the old names still read. - GT-41 A custom guardrail’s checks (
check:, one or a list):judge(its text read by the judge, the default, as before),regex(patterns:),keywords(words:,case_sensitive:),max_length(characters),json_schema(schema:, in YAML or JSON) andpii(emails, phone and card numbers, as the secrets guardrail’spiimasks).min_matches:is how many regex or keyword matches make a catch (1). Each is checked as the file’s read: an unknown check, one without its setting, a pattern or schema that doesn’t read, a judge without text, a threshold outside 0 to 1, all problems. A guardrail of deterministic checks alone needs no model (NeedsJudge). - GT-42 The deterministic checks run first, on the whole content (
Deterministic,Evaluate): a catch is the verdict, with which check and why, and the judge isn’t asked; when they catch nothing, the judge is asked only if the guardrail names it, else it passes. In Blitz (Workspace.judgeGuardrail) and at a gateway (pkg/guardrails). - GT-43 A threshold (
threshold:, 0 to 1): the judge answers a score too, how surely the content breaks the guardrail, and the guardrail acts when the score is at least the threshold, whatever the judge’s word; without one, the judge’s pass or fail as before. A score off the scale, or none, reads as the verdict’s (0 for pass, 1 for fail). - GT-44 A verdict says its score and which check decided (
Verdict.Score,Check); a gateway’s findings carry them (guardrails.Finding.Score,Check), so its request log says what acted and how surely. - GT-45 At a gateway (
pkg/guardrails), custombefore_modelguardrails check what’s sent (Set.Prompt; one that blocks refuses the request), and customafter_modelones the answer: while it streams, those of checks that work piece by piece (regex,keywords,pii;Streamable) on the held window, one that blocks withholding the rest (Output); and the rest on the whole answer once it’s in (Set.Answer), one that blocks replacing it, or, once streamed, saying so at its end.
A custom output guardrail judges the answer once it’s complete, so a streamed answer is shown before it’s withheld. Limits count the files the turn changed by writes the engine sees, not by shell commands.