Policy Configuration
Policy groups control what flows through the relay. Each policy group is a Rego file (Open Policy Agent’s policy language) that defines which middleware rules to apply. Rego gives you conditional logic, time-based gating, and the ability to combine multiple rules in a single group. Policy groups are applied through a two-step process:- Create a policy group with Rego source that defines the middleware rules
- Create a policy binding that attaches the group to a tenant, agent, or subscription
How the Middleware Pipeline Works
enabledLegs:
How Evaluation Works
When a message flows through the relay:- The system finds all active bindings that match the current tenant, agent, and subscription
- For each binding, the associated policy group’s Rego file is evaluated with the request context as input
- The Rego file returns a list of middleware configs to execute
- Each middleware config is instantiated and executed in the specified order
- If any middleware returns
BLOCK, the message is rejected
order field.
Rego File Structure
Every policy group’s Rego file must follow this structure:Middleware Types
Skill Restriction
Control which skills an agent is allowed to use. You can allowlist or blocklist skills by ID, name, or tag.Regex Detection
Match message content against a regular expression.PII Detection (Presidio)
Detect personally identifiable information using Microsoft Presidio.Supported Presidio Entity Types
Supported Presidio Entity Types
PII Detection (AWS Comprehend)
Detect PII using AWS Comprehend.Rate Limiting
Throttle request volume. Three strategies are available: Sliding Window:Human-in-the-Loop (HITL)
Pause messages for manual human approval before they reach the target agent.Conditional Logic with Rego
This is where OPA’s power comes in. Instead of static rules, you can use Rego’sif statements to activate rules conditionally based on the request context, time of day, day of week, and more.
Available Input Context
Every Rego evaluation receives this input:Time-Based Activation
Activate rules only during specific time windows using OPA’s built-intime.* functions with input.timestampNanos:
Combining Always-On and Conditional Rules
Negation
Apply rules when a condition is NOT met:Common Time-Gating Patterns
Business hours only (Mon-Fri 09:00-17:00 UTC):Future Possibilities
Rego supports many more patterns that can be used as we enrich the input context:- Tenant-specific overrides - different rules per tenant ID
- Agent metadata matching - rules based on agent properties like name and group
- Dynamic config values - threshold values computed from input data
Policy Actions
Every detection rule requires anaction that determines what happens when a match is found:
Creating a Policy Group
- Rego syntax is checked
- Each middleware config is validated against its type-specific schema
- Invalid configs are rejected with detailed error messages
Testing Before Saving
Use the evaluate endpoint to dry-run your Rego without creating a group:timestamp to test at a specific point in time. When omitted, the current server time is used:
Policy Bindings
Bindings attach a policy group to a scope. Three levels are available:When multiple bindings apply to a message, they are evaluated in
priority order (lower number = higher priority). Within each binding’s policy group, middlewares execute in order field sequence. All matching middlewares from all applicable bindings are applied.Evaluation Order
BLOCK, the chain short-circuits and the message is rejected.
Create Bindings
Tenant-level (applies to all agents):Versioning
Both policy groups and bindings are versioned using semantic versioning (e.g.1.0.0, 2.0.0).
- Updating a group creates a new version. The old version is disabled automatically.
- Upgrading a binding points it to the latest group version via
POST /v1/policy-bindings/{id}/upgrade. - Version history is available via
GET /v1/policy-groups/{id}/history.
Ownership
Every policy group has a primary owner and an optional secondary owner (escalation contact). Ownership can be transferred viaPOST /v1/policy-groups/{id}/transfer-ownership.
Example: Full Setup
Next Steps
Human-in-the-Loop
Set up manual approval workflows for sensitive operations.
Monitoring & Audit
View policy enforcement events and audit trails.
