compliorAgent() extends the base complior() wrapper with 5 agent-specific hooks that enforce constraints defined in an Agent Passport.
AgentConfig
AgentConfig extends MiddlewareConfig with these fields:
| Field | Type | Default | Description |
|---|---|---|---|
passport | Record<string, unknown> | required | Agent Passport JSON |
budgetLimitUsd | number | From passport | Session budget cap in USD |
onBudgetExceeded | 'warn' | 'block' | 'block' | Action when budget exceeded |
onPermissionDenied | 'warn' | 'block' | 'block' | Action when method is denied |
toolCallAction | ToolCallAction | 'block' | How to handle denied tool calls |
onToolCallDenied | (denied: DeniedToolCall[]) => void | undefined | Callback for denied tool calls |
onAction | (entry: ActionLogEntry) => void | undefined | Audit callback for each LLM call |
circuitBreaker | CircuitBreakerConfig | undefined | Circuit breaker settings |
Passport Field Mapping
The SDK reads these fields from the passport object:| Passport Path | Hook | Behavior |
|---|---|---|
permissions.denied[] | Permission | Methods in this list are blocked |
permissions.tools[] | Tool-call permission | Allowed tool names |
constraints.prohibited_actions[] | Permission | Action names that are blocked |
constraints.rate_limits.max_actions_per_minute | Rate limit | Sliding window cap |
constraints.budget.max_cost_per_session_usd | Budget | Session cost limit (overridden by budgetLimitUsd) |
Hook Pipeline
Agent hooks are added around the standard compliance hooks:Permission Enforcement
The permission pre-hook blocks API calls based on the passport:Rate Limiting
Sliding 60-second window based on passport constraints:Budget Tracking
Estimates token cost from response metadata and accumulates across the session:budgetLimitUsd is not set, the SDK falls back to passport.constraints.budget.max_cost_per_session_usd.
Circuit Breaker
3-state machine that suspends the agent after consecutive errors (Art.14(4)(b)):| Field | Type | Default | Description |
|---|---|---|---|
errorThreshold | number | 5 | Consecutive errors to trip |
windowMs | number | 60000 | Sliding window for error counting |
cooldownMs | number | 30000 | Cooldown before half-open probe |
onTrip | (state) => void | undefined | Callback on state transitions |
CircuitBreakerError until cooldown elapses. In half-open, one probe call is allowed — success resets to closed, failure re-opens.
Action Logging
Every LLM call produces anActionLogEntry via the onAction callback:
Tool-Call Permission
The tool-call post-hook inspects LLM responses for tool/function calls and validates them against the passport:passport.permissions.tools[]— allowlist (only these tools permitted)passport.permissions.denied[]— denylist (these tools blocked)toolCallAction—'block'(remove denied calls) or'warn'(pass through with warning)onToolCallDenied— callback with details of denied tool calls
Agent Passport
Create and manage Agent Passports.
Error Handling
Agent-specific errors: Permission, Budget, RateLimit, CircuitBreaker.