Note: This is a user-friendly guide to writing AIP policies. For the formal specification, see AIP v1alpha1.Complete reference for AIP policy YAML files (
agent.yaml).
Table of Contents
Overview
AIP policies are declarative YAML files that define what tools an agent can use and under what conditions. The policy is loaded at proxy startup and evaluated for everytools/call request.
Design principle: Default deny. If a tool is not explicitly allowed, it’s blocked.
Schema
Metadata
Example:
Spec Fields
mode
Controls whether policy violations are enforced or just logged.allowed_tools
Allowlist of tool names that the agent can invoke. Tool names must exactly match what the MCP server reports.tool_rules with action: allow, it will be blocked.
Tool Rules
Fine-grained control over individual tools. Each rule can specify an action and argument validation.Structure
Actions
Block Action
Explicitly deny a tool:Ask Action (Human-in-the-Loop)
Require user approval for sensitive operations:- Native OS dialog appears: “Allow tool ‘run_training’?”
- User clicks “Allow” or “Deny”
- If no response in 60 seconds: auto-deny
Argument Validation
Useallow_args to validate tool arguments with regex patterns:
- Regex must match the entire argument value (implicit
^...$) - If any
allow_argspattern fails, the request is blocked - Arguments not in
allow_argsare not validated
Rate Limiting
Limit how often a tool can be called:<count>/<period> where period is second, minute, or hour.
When rate limit is exceeded:
- Request is blocked with JSON-RPC error code
-32003 - Audit log records
RATE_LIMITEDevent
Identity Configuration (v1alpha2)
Configure agent identity and session management.Fields
Session Binding Modes
Server Configuration (v1alpha2)
Configure the built-in HTTP server for remote validation.Fields
DLP Configuration
Data Loss Prevention scans tool responses for sensitive patterns and redacts matches.Structure
Built-in Pattern Library
Redaction Output
Matched content is replaced with:[REDACTED:<RuleName>]
Examples
Read-Only Policy
GPU/ML Policy
Prompt Injection Defense
Monitor Mode (Testing)
Validation
Policy File Validation
AIP validates policies at startup. Common errors:Common Error Codes
Testing Policies
-
Dry run with monitor mode:
-
Check audit logs:
-
Verbose logging:
Best Practices
- Start restrictive: Begin with minimal
allowed_tools, expand as needed - Use monitor mode first: Test policies before enforcement
- Review audit logs: Regularly check for unexpected tool usage
- Version your policies: Use semantic versioning in metadata
- Document decisions: Add comments explaining why tools are blocked
- Separate policies per agent type: Different agents need different permissions