When to use policies
Use policies when you need to:- Block dangerous operations before they execute
- Modify inputs to add safety bounds or fix common issues
- Provide guidance without blocking execution
- Audit decisions for compliance and debugging
Policy structure
Every policy extendsDirectedIntuition and implements the advise method:
Three types of actions
Hints (advisory)
Use hints to provide guidance without blocking:Interventions (modify)
Use interventions to fix inputs or add safety bounds:Vetoes (block)
Use vetoes to completely block dangerous operations:governance_mode="enforce".
Common patterns
Pattern: Regex-based detection
Pattern: Risk scoring
Pattern: Context-aware policies
Testing policies
Test policies in isolation without running full episodes:Wiring policies
CLI
Python
Multiple policies
Chain multiple policies by creating a composite:Policy identity in artifacts
DirectedIntuition.hint()/intervene()/veto() return IntuitionEvent with default policy metadata (policy_id="unspecified", policy_version="0.0.0"). To keep artifacts auditable, set identity fields before returning:
Best practices
Test edge cases thoroughly. Policies are security-critical—test empty inputs, unicode, and boundary conditions.
Troubleshooting
Policy not being called
- Verify
intuition=Trueorintuition=MyPolicy()is passed tons.run()
Veto not blocking
- Ensure you’re returning the result:
return self.veto(...)not justself.veto(...) - Check that the condition actually matches your input
- Ensure governance is enforcing:
ns.set(governance_mode="enforce")
Intervention not applied
- Verify your
patchdictionary has the correct keys - Check the event timeline to see if the intervention was recorded
Next steps
Governed Side Effects
Step-by-step tutorial for enforcing side-effect governance.
Governance guide
Configure planner modes for different governance levels.

