Judge guardrails
Last updated: 2026-11-26T03:21:52-03:00 (UTC-3)
A judge guardrail uses one of your evaluators as a guardrail: before the request reaches the provider (input) or before the answer reaches the app (output), the gateway asks the evaluator’s judge model about the text and acts on its verdict. Use it for rules that a pattern or a classifier cannot express (“does this answer promise a refund?”, “is this question about another customer?”).
A judge adds a model call to every request it checks, so it adds latency and cost by design. Use a small, fast judge model, keep max_tokens low, and try it in monitor mode first.
| Flag | What it turns on |
|---|---|
judge_guardrails |
Guardrail provider type judge, the guardrails backed by a judge in an alias’s Used by, and the dataset of guardrail cases. Off by default. A tenant flag: with plan entitlements a team’s plan must include it. Needs guardrails and evaluators |
How to turn it on
Section titled “How to turn it on”- Create an evaluator of the team whose traffic it will check (Evals → Evaluators). It must be an LLM judge or a rule evaluator with pass criteria (or boolean output): a
failassessment is what blocks. A decision model or a JavaScript evaluator is refused.{{output}}is the text being checked at either stage;{{input}}is the request text at input and empty at output. - Publish it. The guardrail always runs the published version; publishing a new version changes the guardrail within 15 seconds.
- Measure it first (optional, recommended): Evaluate on guardrail cases below.
- Add the guardrail, in monitor mode:
features: guardrails: true evaluators: true judge_guardrails: trueguardrails: - id: no-refund-promises name: No refund promises mode: monitor # monitor first; block when you trust it models: [support-chat] stages: [output] provider: type: judge evaluator: ev_6a1f0c2b9d3e4f5a6b7c8d9e # the evaluator's ID max_tokens: 64 # 16-600, default 64 max_input_chars: 8000 # 100-100000, default 8000 timeout: 3s # 100ms-30s, default 5s on_error: block # block (default) or allow- Read what it would have done on the request log (guardrail outcome
would_block) and on the evaluation results of the evaluator, then switchmodetoblock.
The console has the same fields in Guardrails → New guardrail → Evaluator (judge).
What a check does
Section titled “What a check does”- Pass (or an assessment of
none): the request goes on. - Fail: in block mode the request is refused with
400 guardrail_blockedat input (the provider is never called), and the answer is replaced by the guardrail’s refusal at output (the generation was already billed). In monitor mode nothing changes; the outcome iswould_block. - The judge cannot answer (its model failed, the timeout passed, the text is longer than
max_input_chars, the evaluator was deleted or unpublished, the flag or the team’s plan is off):on_errordecides.blockanswers503 guardrail_unavailable, a different code from a content block;allowlets the request through and recordserror_allowed. A judge guardrail never blocks without a verdict or your expliciton_error: block. - Text longer than
max_input_charsis never cut: the check fails astext_too_large. At output an answer that cannot be checked is always withheld, whateveron_errorsays. - A stream cannot be judged whole: a streamed request on an alias with an output judge guardrail is refused before it is sent (
400 guardrail_output_unsupported).
Who may judge whose text
Section titled “Who may judge whose text”The evaluator must belong to the request’s team, or to a team in the same organization. A request of another organization fails the check with evaluator_out_of_scope (and on_error decides): one tenant’s evaluator never reads another tenant’s text, and its definition is never used for another tenant’s traffic.
Cost, latency and recursion
Section titled “Cost, latency and recursion”- The judge’s call is a helper call of the request’s own team (origin
helper, kindguardrail, parent the request), made as the request’s key narrowed to the judge alias. It is budgeted, rate-limited and priced like any other traffic of that team, and its request ID is<request_id>.guardrail-judge.0(input) or<request_id>.guardrail-judge-output.0(output). - The team’s own ceiling (team policies), its plan and the judge alias’s model policies apply to the call: the judge alias comes from a tenant’s evaluator, so it gets no exemption. A refusal is a check that failed, and
on_errordecides. - The request key’s own model list is replaced by the judge alias for this one call, as for a moderation guardrail: the key never asked for the judge, so its list does not decide; the team’s ceiling does.
- One attempt only, bounded by
timeoutandmax_tokens. The evaluator’s own temperature applies; its ownmax_tokensis replaced by the guardrail’s. - The call is a child span of the guardrail span in the request’s trace (stored, and over OTLP), so the trace shows the guardrail, its judge request and that request’s provider attempt.
- A call a judge makes (an evaluator, an experiment or a judge guardrail) is never checked by a judge guardrail, so a guardrail on the judge’s own alias cannot call itself.
- Measured cost on the request path: judge guardrails performance. The gateway adds about 5 ms at the median on top of the judge model’s own time.
Keeping it working
Section titled “Keeping it working”- An evaluator that an enabled judge guardrail runs cannot be disabled or deleted, and a version the guardrail could not run (a decision model, JavaScript, no pass criteria) cannot be published, while the guardrail depends on it: the API answers
409 evaluator_in_usenaming the guardrail. Change or disable the guardrail first. Pausing it is allowed: a paused evaluator stops judging live traffic and still backs the guardrail. Deleting the evaluator’s whole team is not stopped by this rule: the guardrail then fails its checks and counts as misconfigured. - A judge guardrail that cannot reach a decision for a reason of configuration (the flag, the team’s plan, an evaluator out of scope or gone) counts
outcome="misconfigured"ongateway_guardrail_findings_totalfor each check and logsjudge_guardrail_misconfiguredat most once a minute per guardrail and reason.on_errorstill decides each check, so watch this signal whenon_errorisallow. - Scope a judge guardrail to the teams of its evaluator’s organization with guardrail policies: the other organizations’ requests always fail the check with
evaluator_out_of_scope.
Every decision is a result
Section titled “Every decision is a result”Each check is written, off the request path, as an evaluation result on the request, in the request’s team: the evaluator’s name and version, the assessment, the judge’s explanation (encrypted, for content readers), the judge cost from the ledger, and in its metadata the guardrail, the stage, the mode, the decision (pass, blocked, would_block, error_blocked, error_allowed) and the latency. The usual analytics answer “how much did this guardrail cost” and “how often did it block”: group evaluation results by evaluation with judge_cost_usd and evaluation_fail. A check that never reached an evaluator (flag off, not entitled, out of scope) writes no result; the request log still records its outcome.
Evaluate on guardrail cases
Section titled “Evaluate on guardrail cases”The gateway ships labeled guardrail cases (prompt injection, PII, secrets). POST /api/v1/admin/evals/datasets/from-guardrail-cases copies them into an evaluation dataset of your team (team_id, optional name and frameworks); each item’s expected output is fail (must be stopped) or pass. Run an experiment with your evaluator on it before it guards traffic. A judge guardrail can also be measured in Guardrails → Catalog → Evaluate, which runs the judge as the evaluator’s own service account.
Where it shows
Section titled “Where it shows”- The guardrail span:
evaluator_id,judge_request_idand the outcome. - An alias’s Used by panel (with
alias_evaluator_usage): the judge guardrails backed by an evaluator that judges on that alias, and, for readers of guardrails, every guardrail that checks the alias.
See also
Section titled “See also”Guardrails · Evaluators · Evaluation results · Route experiments