Policy Engine
The Radium Policy Engine provides fine-grained control over tool execution to ensure security and prevent unwanted operations. It enables workspace-specific and enterprise-ready security policies with rule-based enforcement.
Overviewβ
The policy engine allows you to:
- Control which tools agents can execute
- Set approval requirements for sensitive operations
- Configure workspace-specific security policies
- Enforce enterprise security requirements
- Prevent accidental destructive operations
Featuresβ
- TOML-based configuration - Simple, declarative policy rules
- Priority-based matching - Admin > User > Default priority tiers
- Pattern matching - Glob patterns for tool names and arguments
- Approval modes - Yolo, AutoEdit, and Ask modes for different security levels
- Session constitutions - Per-session rules for temporary constraints
- Hook integration - Works with Radium's hook system for extensibility
Configurationβ
Policy rules are configured in .radium/policy.toml in your workspace root.
Basic Structureβ
# Approval mode: yolo, autoEdit, or ask
approval_mode = "ask"
# Policy rules
[[rules]]
name = "Rule name"
priority = "user" # admin, user, or default
action = "allow" # allow, deny, or ask_user
tool_pattern = "read_*"
reason = "Optional reason for this rule"
Approval Modesβ
yolo- Auto-approve all tool executions (use with caution)autoEdit- Auto-approve file edit operations, ask for othersask- Ask for approval on all tool executions (safest, default)
Priority Levelsβ
Rules are evaluated in priority order (highest first):
admin- Highest priority, typically for security-critical rulesuser- Medium priority, for user-defined policiesdefault- Lowest priority, for default system policies
The first matching rule wins. If no rules match, the approval mode default is applied.
Actionsβ
allow- Allow tool execution without promptingdeny- Block tool executionask_user- Require user approval before execution
Pattern Matchingβ
Tool Name Patternsβ
Use glob patterns to match tool names:
# Match all tools starting with "read_"
tool_pattern = "read_*"
# Match specific tool
tool_pattern = "write_file"
# Match MCP tools
tool_pattern = "mcp_*"
# Match tools from specific MCP server
tool_pattern = "mcp_server1_*"
Argument Patternsβ
Optionally match tool arguments:
[[rules]]
name = "Block dangerous commands"
priority = "admin"
action = "deny"
tool_pattern = "run_terminal_cmd"
arg_pattern = "rm -rf *"
reason = "Prevent accidental deletion"
Argument patterns can match:
- Individual arguments
- The full argument string (space-joined)
Example Configurationsβ
Safe Default Configurationβ
approval_mode = "ask"
[[rules]]
name = "Allow safe file operations"
priority = "user"
action = "allow"
tool_pattern = "read_*"
reason = "Safe read operations are always allowed"
[[rules]]
name = "Require approval for file writes"
priority = "user"
action = "ask_user"
tool_pattern = "write_*"
reason = "File writes require user approval"
[[rules]]
name = "Deny dangerous shell commands"
priority = "admin"
action = "deny"
tool_pattern = "run_terminal_cmd"
arg_pattern = "rm -rf *"
reason = "Prevent accidental deletion"
Enterprise Security Configurationβ
approval_mode = "ask"
# Admin rules (highest priority)
[[rules]]
name = "Block all network operations"
priority = "admin"
action = "deny"
tool_pattern = "http_*"
reason = "Enterprise policy: no external network access"
[[rules]]
name = "Block file system operations outside workspace"
priority = "admin"
action = "deny"
tool_pattern = "write_file"
arg_pattern = "../*"
reason = "Enterprise policy: workspace isolation"
# User rules (medium priority)
[[rules]]
name = "Allow safe operations"
priority = "user"
action = "allow"
tool_pattern = "read_*"
[[rules]]
name = "Require approval for edits"
priority = "user"
action = "ask_user"
tool_pattern = "write_*"
CLI Commandsβ
List Policiesβ
# List all policy rules
rad policy list
# Verbose output with table format
rad policy list --verbose
# JSON output
rad policy list --json
Check Policy Evaluationβ
# Check if a tool would be allowed
rad policy check read_file config.toml
# Check with multiple arguments
rad policy check run_terminal_cmd "rm -rf /tmp/test"
# JSON output
rad policy check write_file test.txt --json
Validate Policy Fileβ
# Validate default policy file
rad policy validate
# Validate specific file
rad policy validate --file /path/to/policy.toml
Initialize Policy Fileβ
# Create default policy.toml template
rad policy init
# Overwrite existing file
rad policy init --force
Session Constitutionsβ
Session constitutions allow you to add temporary rules for a specific execution session. These rules are automatically cleaned up after 1 hour of inactivity.
Use Casesβ
- Temporary restrictions for a specific task
- Per-session security constraints
- Dynamic policy adjustments
Integrationβ
Session constitutions are managed through the ConstitutionManager and integrated with workflow execution. Rules are combined with static policy rules, with session rules taking precedence when there are conflicts.
Workflow Integrationβ
The policy engine is automatically integrated with workflow execution:
- Policy engine is initialized from
.radium/policy.tomlif present - Constitution manager is available for session-based rules
- Policy evaluation happens during tool execution
- Decisions are logged for audit trails
Architectureβ
Componentsβ
- PolicyEngine - Core evaluation engine
- PolicyRule - Individual rule definition
- ConstitutionManager - Session-based rule management
- PolicyDecision - Evaluation result
Evaluation Flowβ
- Tool execution request received
- BeforeTool hooks executed (if registered)
- Rules evaluated in priority order (Admin > User > Default)
- First matching rule's action returned
- If no match, approval mode default applied
- AfterTool hooks executed (if registered)
Best Practicesβ
- Start with Ask mode - Use
askapproval mode for maximum safety - Use Admin priority sparingly - Reserve for critical security rules
- Test policies - Use
rad policy checkto test rules before deployment - Document rules - Always include
reasonfields for clarity - Validate patterns - Use
rad policy validateto check syntax - Version control - Commit policy.toml to version control for team sharing
Troubleshootingβ
Pattern Not Matchingβ
- Check glob pattern syntax
- Verify tool name format (use
rad policy checkto test) - Ensure pattern doesn't have extra spaces
Rule Not Appliedβ
- Check rule priority (higher priority rules win)
- Verify rule order (first match wins)
- Ensure approval mode default isn't overriding
Performance with Many Rulesβ
- Rules are sorted by priority on load
- Evaluation stops at first match
- Consider consolidating similar rules