Guards
Guards are optional fields on a policy rule that add an extra check on top of the rule’s action. They run at request time, before the request is forwarded upstream.
Guards are checked after the rule’s target and conditions match. Within a rule the order is: token guard, then content guard, then the rule’s own action.
Token Guards
Token guards cap the size of LLM requests before they reach the upstream provider. They apply to rules whosetarget.kind is llm_model or llm_endpoint.
Fields
If a token guard fires, the request is denied whatever the rule’s
action is, including allow. The gateway returns HTTP 403 with a message like Policy denied: Token guard violated: input tokens ~9120 exceeds limit 8000.
Example
max_tokens exceeds 2,048.
maxInputTokens uses a character-count heuristic (chars / 4) at request time. It is not an exact token count. Use it to catch runaway prompts, not for precise billing.Content Guards
Content guards run Igris detectors on request content, and optionally on the upstream response.Fields
What action does
contentGuard.action decides the outcome of a detector match for rules whose own action is allow or alert:
Two other cases do not use
contentGuard.action:
- A rule with action
denyalways denies, whatever the guard says. A guard never makes a rule less strict. - A rule with action
redactnever blocks, whatever the guard’sactionis. It masks whatever the detectors match.
deny.
Example: Redact PII before forwarding
[REDACTED:<detector-id>]. The upstream call proceeds with the redacted content. A redact guard on an allow or alert rule masks only when a scanned text field (listed below) matched; a rule with action redact walks every string in the request body. For MCP rules with action redact, it masks the tool call’s arguments.
Example: Block secrets in LLM prompts
messages content, prompt, system, input, and Gemini contents. Matches outside those fields are not caught by a deny or alert guard. A rule with action redact does mask them.
Response inspection
WithinspectResponse: true, the detectors also run on the upstream response:
- Masking: if the rule action or the guard action is
redact, matches in a non-streaming LLM response are masked before it is returned. - Otherwise: a match does not block the response. Igris logs an extra alert for it (“response violation”) and sends the Policy Denials webhook.
- Streaming: streamed LLM responses are scanned after the stream has finished, so they are never masked. A match is logged as a response violation, even for
redactguards. - MCP: responses are masked only on rules with action
redact. Other MCP rules do not act on response matches.
Built-in packs
GET /api/v1/detectors/catalog lists every built-in detector.
Custom detectors
Custom detectors work indeny, alert, and redact guards and in response inspection. Create and manage them in the policy editor or through the API at https://api.igrisecurity.com/api/v1/detectors/custom. Three kinds are supported: regex, keywords, and luhn. A slug matches ^[a-z0-9-]{1,50}$. Reference a saved detector in any detectors array as custom:<slug>. Creating and editing custom detectors needs the policies:write permission.
Combining Guards with Actions
Related
- Policies — how rules are structured, evaluated, and rate-limited
- Tool Calls — how MCP tool calls flow through the proxy
- Identity & Metadata — how user and metadata context reach the policy engine