nodeId) within the same workspace. When no agent-scoped policy exists, the middleware treats the agent as having no enforcement (allow-all). Having the SDK present is not sufficient without an active policy.
How It Works
The middleware resolves policies using a scope hierarchy:- Base policy: workspace-level policy (no
nodeId), applies to all agents by default. - Agent policy: node-specific policy keyed by
nodeId, overrides the base policy for that agent.
nodeId from the runtime agent state header (x-agent-state) and fetches the corresponding policy based on the configured scope.
Configuration
Remote Policy Source (Dynamic)
For production environments, configure the middleware to fetch policies dynamically pernodeId:
These examples focus on policy-source fields. Keep your base middleware options (
signer, otel, sec0, and other required fields) from Quickstart.Local Policy (Static)
For local development or simple setups, pass the policy YAML directly. Note that static policies apply uniformly. Agent scoping requires a remote source that resolves per-nodeId.
Policy Source Options
Scope Behavior
How nodeId Is Resolved
The middleware determines the effectivenodeId at runtime using this priority:
- Runtime header: extracted from the
x-agent-stateheader on the incoming tool call (set by upstream agent decorators) - Configured default: the
nodeIdfield in the policy source config - None: falls back to base policy (or throws in
"agent"scope)
Example: Different Policies Per Agent
A common pattern is giving different agents different compliance rules. For example, an EHR agent may need HIPAA compliance packs while an order agent only needs basic security rules.- Tool calls from
EhrAgentare enforced with theehr-agentpolicy (e.g., HIPAA compliance packs) - Tool calls from
OrderAgentare enforced with theorder-agentpolicy (e.g., basic security rules) - If either agent has no scoped policy, it falls back to the base workspace policy