Vaikora › Blog › Product Updates
Four things an LLM policy gateway checks before allowing an action, and what happens when one fails
An LLM policy gateway sitting inline between an agent and a model call does not make a single binary decision. It runs several independent checks in sequence, and any one of them can produce a block, a modify, or a require-approval outcome before the action reaches the model. Understanding which checks exist and what each one does matters when you are designing policies or debugging why a call was blocked.
The four checks, in order
1. Identity and session context
The gateway resolves who is calling. For an AI agent, that means the agent identity, the session token, and any role bindings that were established when the session opened. This is not the same as authentication at the API boundary. The gateway asks: does this identity have a standing permission to invoke this tool or model endpoint at all? If not, the call stops here without any content inspection.
2. Tool and endpoint authorization
Once identity is confirmed, the gateway checks whether the specific tool or model endpoint being called is on the allow list for this policy context. A single agent may have permission to call a summarization endpoint but not a code execution endpoint. The check is deterministic: the same identity plus the same endpoint either resolves to allowed or it does not, regardless of what the prompt contains.
3. Content and parameter inspection
This is where the payload is examined. The gateway runs the prompt, the tool parameters, or both through its content inspection modules. What it looks for depends on policy configuration, but common checks include credential and secret patterns in the outbound message, PII categories that should not cross the boundary (card numbers, health identifiers, national ID formats), prompt injection patterns embedded in user-supplied text, and disallowed topic categories.
A concrete example: an agent passes a customer support query to a summarization model. The user's message contains what looks like a credit card number. The content inspection module flags the PAN pattern. The gateway's policy is set to modify in this case, so it redacts the number before the payload reaches the model, then writes the original and modified versions to the audit log. The model never sees the raw PAN. The agent receives the summarized response as normal.
4. Output inspection on the return path
The check runs in both directions. When the model response comes back, the gateway inspects it before returning it to the agent. This catches model-generated content that violates policy: an LLM that hallucinates a real person's details into a response, generates disallowed content in a creative task, or echoes back a secret it should not have received. The outbound and inbound checks are separate policy rules, so you can block outbound PII while applying a different rule set to inbound responses.
What a decision record contains
Every decision, whether allow, block, modify, or require-approval, produces a signed record. The record includes the agent identity, the tool or endpoint called, the policy rule that matched, the decision outcome, and a timestamp. For modify decisions, the record stores both the original payload and the modified version. Each record is written into a SHA-256 hash-chained audit log, so any tampering with an earlier record breaks the chain from that point forward. That property is what makes the log usable in a post-incident investigation rather than just a compliance artifact.
Why the order matters
Running identity and endpoint checks before content inspection is not an optimization. It means the gateway never spends compute on content analysis for calls that have no authorization in the first place. At 10,000+ actions per second throughput, skipping unnecessary content inspection for unauthorized calls keeps enforcement latency at P50 8ms and P99 45ms without sacrificing coverage.
It also means policy failures are attributable. If a block fires at the endpoint authorization step, the investigation starts with identity and role configuration. If it fires at content inspection, the investigation starts with the payload. That distinction matters during incident response.
What to check in your own setup
If you are configuring an LLM policy gateway, work through each layer separately:
- Confirm that identity resolution is happening at the session level, not just at the API key level.
- Review your endpoint allow lists for each agent role. Gaps here are often where over-permissioning lives.
- Run test payloads with known PII and injection patterns against your content inspection rules before you go to production. The modify outcome is worth testing specifically, because it is where redaction logic can be verified end to end.
- Check your output inspection rules separately from your input rules. Many configurations apply thorough input inspection but leave output inspection unconfigured.
Vaikora runs all four checks inline as a proxy, with no SDK migration required across the 12 LLM providers it supports. The gateway is available as a self-hostable MCP-compatible proxy under MIT license on PyPI as `vaikora-guard-mcp`, and the control plane is available on AWS Marketplace and Azure Sentinel Content Hub.
See Vaikora enforce policy on your AI
Open-core AI runtime control. Self-host the MIT gateway free, or run the hosted Control Plane.
Get a demo Self-host the gateway
Vaikora