Custom permissions policy
from typing import Any, Mapping
from loomflow import Agent
from loomflow.core.types import PermissionDecision, ToolCall
class BusinessHoursPermissions:
"""Block destructive tools outside 9am-5pm local time."""
async def check(
self,
call: ToolCall,
*,
context: Mapping[str, Any],
) -> PermissionDecision:
if not call.is_destructive():
return PermissionDecision.allow_()
from datetime import datetime
now = datetime.now()
if 9 <= now.hour < 17:
return PermissionDecision.allow_()
return PermissionDecision.deny_(
f"destructive calls disabled outside business hours (now {now:%H:%M})"
)
agent = Agent("...", permissions=BusinessHoursPermissions())Same pattern for any custom policy. Geofencing, role-based access,
cost-tier gating, etc. Just satisfy the Permissions protocol.
Last updated on