Skip to main content

Policy Module

The policy module provides policy-based execution control for agents, allowing you to define rules for what agents can and cannot do.

Installation

Features

  • Define rules for what agents can/cannot do
  • Tool execution policies
  • Resource access control
  • Rate limiting and quotas

Quick Start

Classes

PolicyEngine

Main engine for evaluating policies.

Methods

Policy

A collection of rules.

Attributes

PolicyRule

A single rule in a policy.

Attributes

PolicyResult

Result of a policy check.

Attributes

PolicyAction

Enumeration of policy actions.

Convenience Functions

create_deny_tools_policy

Create a policy that denies specific tools.

create_allow_tools_policy

Create a policy that only allows specific tools.

create_read_only_policy

Create a read-only policy.

Usage Examples

Basic Policy

With Agent

Conditional Rules

Multiple Policies

Best Practices

  1. Use wildcards - Pattern matching for flexible rules
  2. Set priorities - Higher priority policies are evaluated first
  3. Provide reasons - Clear reasons help debugging
  4. Use convenience functions - Pre-built policies for common cases
  5. Test policies - Verify rules work as expected