Policy Engine

Policy-based execution control for agent operations

The policy command manages execution policies for agent operations.

Quick Start

bash
# List configured policies
praisonai policy list

Usage

List Policies

bash
praisonai policy list

Expected Output:

╭─ Configured Policies ────────────────────────────────────────────────────────╮
│  🛡️ no_delete - Block delete operations (priority: 100)                     │
│  🛡️ read_only - Allow only read operations (priority: 50)                   │
╰──────────────────────────────────────────────────────────────────────────────╯

Check Policy

bash
praisonai policy check "tool:delete_file"

Check Network Egress

bash
praisonai policy check "net:api.example.com"

The net:<host> resource gates outbound requests by destination host. See the Network egress section for allow/deny semantics and host normalization.

Initialize Policies

bash
praisonai policy init

Creates a template .praison/policies.json file.

Python API

python
from praisonaiagents.policy import (
    PolicyEngine, Policy, PolicyRule, PolicyAction, create_network_policy
)

engine = PolicyEngine()

policy = Policy(
    name="no_delete",
    rules=[
        PolicyRule(
            action=PolicyAction.DENY,
            resource="tool:delete_*",
            reason="Delete operations blocked"
        )
    ]
)
engine.add_policy(policy)

result = engine.check("tool:delete_file", {})
print(f"Allowed: {result.allowed}")

# Gate outbound requests by destination host
engine.add_policy(create_network_policy(
    allow_hosts=["api.mycorp.com"],
    deny_hosts=["169.254.169.254"],  # block cloud metadata
))
print(engine.check_network("api.mycorp.com").allowed)      # True
print(engine.check_network("169.254.169.254").allowed)     # False

See Also