Skip to content

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
  1. 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 fail assessment 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.
  2. Publish it. The guardrail always runs the published version; publishing a new version changes the guardrail within 15 seconds.
  3. Measure it first (optional, recommended): Evaluate on guardrail cases below.
  4. Add the guardrail, in monitor mode:
features:
guardrails: true
evaluators: true
judge_guardrails: true
guardrails:
- 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
  1. Read what it would have done on the request log (guardrail outcome would_block) and on the evaluation results of the evaluator, then switch mode to block.

The console has the same fields in Guardrails → New guardrail → Evaluator (judge).

  • Pass (or an assessment of none): the request goes on.
  • Fail: in block mode the request is refused with 400 guardrail_blocked at 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 is would_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_error decides. block answers 503 guardrail_unavailable, a different code from a content block; allow lets the request through and records error_allowed. A judge guardrail never blocks without a verdict or your explicit on_error: block.
  • Text longer than max_input_chars is never cut: the check fails as text_too_large. At output an answer that cannot be checked is always withheld, whatever on_error says.
  • 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).

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.

  • The judge’s call is a helper call of the request’s own team (origin helper, kind guardrail, 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_error decides.
  • 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 timeout and max_tokens. The evaluator’s own temperature applies; its own max_tokens is 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.
  • 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_use naming 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" on gateway_guardrail_findings_total for each check and logs judge_guardrail_misconfigured at most once a minute per guardrail and reason. on_error still decides each check, so watch this signal when on_error is allow.
  • 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.

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.

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.

  • The guardrail span: evaluator_id, judge_request_id and 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.

Guardrails · Evaluators · Evaluation results · Route experiments

m7gtwcontact@m7gtw.com