Vaikora › Blog › Product Updates
How an LLM policy engine decides in under 50ms: the inspection chain from token to verdict
The gap between "we have an AI usage policy" and "that policy runs at the wire level" is exactly where most AI agent incidents happen. A written policy cannot block a data exfiltration call. An enforcement layer can.
This article walks through what actually happens inside an LLM policy engine during the sub-50ms window between an agent action arriving and a verdict being returned.
What the enforcement point receives
An AI agent sends a request. That request is not raw text. By the time it reaches the policy engine, it carries several distinct signals:
- The prompt or message payload (what the agent is about to send to the model, or what the model just returned)
- The tool call intent (which tool, with which parameters)
- The calling identity (which agent, service account, or session)
- The execution context (prior actions in the chain, session state)
Each of these is a separate inspection surface. A policy engine that only reads the message text misses tool parameter injection, identity anomalies, and chained-action patterns that only appear across multiple calls.
The inspection modules
Vaikora's gateway ships six content inspection modules. Each module runs deterministically: identical input produces identical output, every time. That matters for audit because it means you can replay any decision against the recorded input and get the same verdict.
The modules cover:
- Prompt injection detection: pattern and semantic analysis on input text before it reaches the model
- Tool call policy: allow/block/modify decisions on specific tool names and parameter values
- Data classification: inline scanning of payloads for PII, secrets, and sensitive schema before exfiltration
- Output filtering: inspection of model responses before they are returned to the agent or the user
- Identity and session context: policy rules keyed to agent identity, not just content
- Compliance presets: HIPAA, PCI-DSS, GDPR, SOC 2, and ISO 27001 rules shipped as configuration, not custom code
Each module contributes a signal. The policy engine combines those signals and returns one of four verdicts: allow, block, modify, or require-approval.
A concrete scenario
An agent running a customer support workflow calls a CRM tool with the parameter `query: "SELECT * FROM customers WHERE region='EU'"`. That looks like a normal read.
The data classification module flags the response payload: it contains fields matching PII patterns under the GDPR preset. The tool call policy module checks the agent identity and finds the calling session does not have an explicit allow rule for bulk EU customer reads.
Result: the action is blocked before the response is returned to the agent. The session state records the block. The next action in the chain cannot proceed as if the read succeeded, because it did not.
This all happens at P50 8ms, P99 45ms. The agent sees a policy rejection and can be programmed to escalate or halt. The human operator sees the event in the audit log.
The audit chain
Every decision, including allows, is written to a SHA-256 hash-chained audit log. Each entry includes the input, the verdict, the module that triggered it, and the hash of the previous entry. You cannot delete or reorder entries without breaking the chain.
That design answers the investigation question: not just what was blocked, but what was allowed and why. When a post-incident review asks whether a particular agent accessed a particular resource in a 48-hour window, the log gives a deterministic answer.
Where the enforcement sits
The policy engine runs inline between the agent and the LLM or tool endpoint. It is not a sidecar that observes traffic. It is the path traffic takes. If the engine is not reachable, the call does not proceed.
Vaikora supports 12 LLM providers with no SDK migration. The gateway ships as an open-source, MIT-licensed MCP-compatible proxy (available on PyPI as `vaikora-guard-mcp`) plus an enterprise control plane. It integrates natively with Microsoft Sentinel, CrowdStrike Falcon, SentinelOne, and AWS Security Hub, pushing AI agent threat signals into existing detection workflows without custom engineering.
What to check in your own environment
Before deploying any policy engine, answer these three questions:
- Does the enforcement point sit inline before the action executes, or does it observe and alert after?
- Does your inspection cover tool call parameters and agent identity, not just message text?
- Is every decision (including allows) logged in a tamper-evident format you can query during an investigation?
If the answer to any of these is no or unclear, that is the gap to close first. The policy document can wait.
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