The Policy Engine checks each proxied AI call against the rules in an AI system's active guardrail profile, and rejects the call with HTTP 422 when a rule set to Block matches. Nothing needs to change in your app.
If any of these is missing, the proxy forwards the call without checking it. Each AI system's page in the console shows them as a checklist, with a green check for each step that is done, a red cross for each that is not, and a button to fix it where possible.
X-AI-System-Id to choose one.If the engine itself errors (for example, a database outage), the call goes through unchecked, unless the organisation has turned on fail-closed mode, which refuses it instead. See the fail-open guarantee.
The category decides whether a rule checks what you send or what the AI sends back. All request categories behave the same; the name is for organising your rules.
| Category | Checks | Use it for |
|---|---|---|
| Input check | Request | Banned words, prompt size, allowed models |
| Prompt integrity | Request | Prompt-injection phrases |
| Retrieval control | Request | Limits on documents or context passed in |
| Data access | Request | Fields or identifiers that must not be sent |
| Tool permission | Request | Tools or functions the model may not call |
| Human escalation | Request | Requests that need a person's review |
| Audit evidence | Request | Requests you want flagged for audit |
| Output validation | Reply | Words or patterns the AI must not return |
On a chat request, the text checks (Keyword list, Regex and Topic block) read only the newest user message. Earlier turns were already checked when they were sent, so a blocked message doesn't block every later turn, and words in your app's system prompt never trigger a rule. Requests without a message list are read whole. Token limit, Model allowlist and JSON path match always read the whole request. Matching ignores upper and lower case.
| Type | Matches when | Value to enter | Example |
|---|---|---|---|
| Keyword list | Any keyword appears, even inside a longer word | Comma-separated keywords | project falcon, internal only |
| Regex | The regular expression finds a match | The pattern only, without slashes | \b\d{3}-\d{2}-\d{4}\b |
| JSON path match | A field in the body passes the comparison | JSON with path, operator, value | {"path": "temperature", "operator": "gt", "value": 1} |
| Topic block | Every word of a topic appears, in any order | Comma-separated topics | merger acquisition, layoff plan |
| Token limit | Estimated size (characters ÷ 4) is over the limit | A number | 4000 |
| Model allowlist | The body's model doesn't start with a listed name | Comma-separated model names | gpt-4o, claude-sonnet |
Keyword matching finds parts of words: the keyword ass also matches “class”. Use a regex with \b word boundaries for whole words only.
JSON path operators: equals, not_equals, contains, exists, not_exists, gt, lt. Paths use dots and indexes, such as messages[0].role. If the value isn't valid JSON, the whole text is treated as a path with exists.
Block and Require approval change what happens to a call. Every other action records the match, sends a notification and calls your webhook, then lets the call through.
| Action | On a request rule | On an Output validation rule |
|---|---|---|
| Block | Call rejected with HTTP 422; nothing reaches the AI provider | Reply withheld; your app gets HTTP 422 naming the rule. The call is logged as blocked |
| Flag | Match recorded; call goes through | Match recorded |
| Require approval | Call held with HTTP 403 (code approval_required); nothing reaches the AI provider. The call goes to Approvals; once approved, resend it with X-Aegis-Approval (see Human Oversight → Held AI calls) | Recorded like Flag |
| Redact | Recorded like Flag; the text is not changed. Use PII Shield to redact personal data | Recorded like Flag |
| Allow | Recorded like Flag; does not override a Block rule that also matches | Recorded like Flag |
Streaming with reply Block rules. When an AI system has an Output validation rule set to Block, streamed replies are checked in full before any of it is sent, so your app receives the reply all at once, or a 422. Other streams are not affected.
Severity (Low, Medium, High, Critical) is a label. It appears in the 422 response, notifications and webhooks so you can sort and route alerts. It does not change what the action does.
A blocked request returns:
HTTP 422
{
"error": "Policy Engine: prompt blocked by rule \"Block codename\" (Matched keywords: project falcon).",
"violations": [{
"rule": "Block codename", "category": "input_check", "severity": "medium",
"action": "block", "reason": "Matched keywords: project falcon"
}]
}A call held for approval returns:
HTTP 403
{
"error": "Policy Engine: this call needs human approval (rule \"Refunds need finance\"), so it was not sent to the AI provider.",
"code": "approval_required",
"requestId": "3f2c…",
"status": "pending",
"next": "Check GET /v1/actions/3f2c…. Once it is approved, send exactly the same request again with the header X-Aegis-Approval: 3f2c…",
"violations": [{ "rule": "Refunds need finance", "action": "require_approval", ... }]
}Held and blocked calls are both saved in your audit trail, so you can show the control fired.
When you record an agent's tool call with POST /agent/actions, Aegis Guardrails decides whether it needs a human, using the rules of the AI system linked to your project (or the one you name in aiSystemId). Tool permission, Data access and Human escalation rules see { toolName, toolInput }. For example, the JSON path match {"path": "toolInput.amount", "operator": "gt", "value": 500} with the Require approval action marks refunds over $500 as pending.
The agent's own requiresApproval and riskScore can ask for review but can't skip it. If the rules can't be checked, the action is marked pending. The response explains the decision in approvalReason (rule, circuit_breaker, agent_request or policy_unavailable) and lists any matching rules in policyViolations.
Today, actions are recorded after they run. A pending status flags the action for review; it doesn't stop it. Holding an action until someone approves it is on the roadmap.
The circuit breaker sets how strictly an AI system is handled. Change the mode by hand, or set triggers that raise it automatically.
| Mode | Effect on calls |
|---|---|
| Observe | Rules run as normal. The default |
| Monitor | Same as Observe |
| Warn | Calls with any rule match are marked as warned |
| Require approval | Every call is held with HTTP 403 (code approval_required). Agent actions are marked pending approval |
| Restrict | Proxied calls: same as Observe. Agent actions that match a High or Critical rule are marked pending approval |
| Pause / Quarantine / Rollback | Every call is refused with HTTP 503. Agent actions are marked pending approval |
Triggers raise the mode when a count passes a threshold within a time window: Policy violation rate (logged calls with a rule match), Policy blocked rate (logged calls marked blocked) and Sensitive data exposure (logged calls where PII Shield found personal data). Triggers only raise the mode; set it back by hand. Requests rejected with HTTP 422 are not logged calls, so they don't count toward triggers.
None of these are needed for rules to run. Add them for a fuller audit trail.
| Header | Use | Value |
|---|---|---|
| X-Actor-Id | Shows who made the call in Events and the session timeline | Your user's ID in your app |
| X-Session-Id | Groups calls into a session timeline | Any stable ID for the conversation |
| X-End-User-IP | Records the end user's address for incident tracing | The user's IP address, as your server sees it |
| X-AI-System-Id | Chooses a specific AI system instead of the project's | The AI system's ID from its console page |
| X-Project | Files a call under a project when using the main API key | The project ID or slug |
project falcon, Action Block.If the call goes through instead, check the setup checklist on the AI system's page.