Guardrails
Guardrails in Agent Router Enterprise run inline in the gateway data plane as a dynamic module, inspecting the prompt on its way to a model provider and the response on its way back. A guardrail is a project-scoped policy: a set of rules, each pairing a check type (what to detect) with a guardrail provider (how it is detected) and a stage (where on the request path it runs).
Where guardrails run
Evaluation happens in process, as a dynamic module in the gateway data plane, with no sidecar and no extra network hop. Every request that crosses the gateway is inspected on the way in (the prompt, before it reaches any model provider) and on the way out (the model's response, before it reaches the application).
Guardrails inspect large language model (LLM) traffic. Model Context Protocol (MCP) traffic is also proxied by the gateway, but standalone MCP profile requests do not pass through content guardrails; they are governed by identity, access control, and audit. See Guardrails for the request-path detail.
Running at the gateway rather than in application code has two consequences:
- Centralized governance: one policy protects every application in the project, with no per-application safety code and no software development kit (SDK) integration.
- Cost at the edge: a prompt blocked at the gateway never reaches the model provider, so no charge is incurred for a call that would have failed policy.
The core design split drives everything below:
- A check type states what to look for (personally identifiable information, jailbreak, toxicity, and others). There are 23.
- A guardrail provider states how it is detected (regular expression engine, keyword pipeline, machine-learning classifiers, external service). There are five provider kinds.
- A stage states where on the request path the rule runs: input, output, or both.
- Any check type can in principle be served by different providers, so the cost and accuracy point is selected per rule. Providers score, the gateway decides: a provider returns a normalized score between 0.0 and 1.0, and the gateway compares it to the rule's threshold and applies the action.
- Not every combination of the three is implemented. The capability matrix is the authority, and the API validates every rule against it at write time.
Anatomy of a guardrail
A guardrail is a named, project-scoped policy: a collection of rules plus shared settings. A rule is one check type, one provider, an action, a mode, and a stage.
Guardrail-level settings
| Setting | Values | Meaning |
|---|---|---|
| Type | compliance, security, policy, quality, custom, evaluator | What class of concern the guardrail addresses |
| Severity | low, medium, high, critical | Operational severity of a trigger |
| Category | data_privacy, financial, healthcare, government, custom | Domain grouping |
| Failure mode | fail_close (default), fail_open | If evaluation itself fails (provider down, timeout): fail-close blocks the request, fail-open lets it pass. The setting is per path: fail-close where safety dominates, fail-open where availability dominates |
| Evaluation timeout | milliseconds | Per-guardrail evaluation budget (the built-in templates use 3000 to 5000 ms) |
| Triggered response | message template | What the caller sees on a violation; supports {{policy_name}}, {{rule_name}}, and {{violation_details}} substitution |
Rule-level settings
| Setting | Values | Meaning |
|---|---|---|
| Check type | one of the 23 listed below | What to detect |
| Provider | one of the configured provider instances | The guardrail provider that scores the content |
| Action | block, redact | Block stops the request with HTTP 403, plus an optional message and a correlation ID for investigation. Redact masks the matched content (for example [CREDENTIAL_REDACTED]) and lets the request continue |
| Mode | enforce, monitor | Enforce applies the action. Monitor is shadow mode: it records what would have happened and passes content unchanged, which surfaces trigger and false-positive rates on live traffic before enforcement. Monitor rules never break the request flow and are always effectively fail-open |
| Stage | input, output, or both | Run against the prompt, the response, or both. Labeled Run on in the Admin Console and execute_on in the API. Leaving it unset requests both stages, so a check supported on only one stage must have the stage set explicitly or the write is rejected |
| Content type | all, text, image, document, tool, thinking, context | Which kind of content an evaluation ran against. Carried on the evaluation and on the resulting trigger record, not set on the rule in the Admin Console |
| Target | project | Rules apply to the guardrail's whole project |
| Threshold | 0.0 to 1.0 | Violation sensitivity: the gateway flags a violation when the provider score is at or above the threshold (deterministic engines score 1.0 or 0.0) |
Streaming behavior
- If every rule on a stage is monitor mode, evaluation is asynchronous and streaming is unaffected.
- If any rule on the output stage enforces, the response is buffered for evaluation before delivery, so enforcing output guardrails de-stream the response. This is a deliberate correctness trade-off; the operational implications are covered in Guardrails best practices and FAQ.
- Buffering follows the mode, not the action. Both actions buffer when the rule enforces:
redacthas to rewrite content it has already seen, so it de-streams a response exactly asblockdoes. Choosingredactoverblockchanges what the caller receives, never whether the response streams. - Enforcement on the input stage leaves streaming intact. Input rules run before the request is forwarded, so their cost lands on time-to-first-token rather than on the stream, which makes enforce-on-input with monitor-on-output the combination that polices prompts while keeping responses streaming.
- A blocked response is returned as a structured HTTP
403with the error envelope, not as a dropped or truncated stream, precisely because the response was buffered before the violation was found. See Streaming behavior.
Check types
23 check types, in four groups. Each name below is the value used in the Admin Console; the corresponding API constant is CHECK_TYPE_ followed by the upper-cased name, so pii is CHECK_TYPE_PII and factual_consistency is CHECK_TYPE_FACTUAL_CONSISTENCY.