pub struct ActionPolicy {
pub id: String,
pub name: String,
pub mode: EnforcementMode,
pub allowed_tools: Option<HashSet<String>>,
pub blocked_tools: HashSet<String>,
pub max_risk_score: f64,
pub allowed_action_types: Option<HashSet<AgentActionType>>,
pub max_actions_per_session: Option<u32>,
pub allow_unregistered: bool,
}Expand description
Policy for controlling which actions an agent can take.
Combines allowlist/blocklist enforcement, risk score thresholds, action type filtering, and session-level rate limiting into a single evaluable policy.
Use the builder methods to configure, or the convenience constructors
ActionPolicy::permissive and ActionPolicy::restrictive.
Fields§
§id: StringPolicy identifier.
name: StringHuman-readable name.
mode: EnforcementModeEnforcement mode.
allowed_tools: Option<HashSet<String>>Allowed tool IDs (if set, only these tools are permitted).
blocked_tools: HashSet<String>Blocked tool IDs (these tools are always denied).
max_risk_score: f64Maximum risk score allowed (tools with higher risk are blocked).
allowed_action_types: Option<HashSet<AgentActionType>>Allowed action types (if set, only these types are permitted).
max_actions_per_session: Option<u32>Maximum total actions per session.
allow_unregistered: boolWhether to allow actions on unregistered tools.
Implementations§
Source§impl ActionPolicy
impl ActionPolicy
Sourcepub fn new(id: &str, name: &str) -> Self
pub fn new(id: &str, name: &str) -> Self
Create a new action policy with sensible defaults.
Defaults: enforce mode, no allowlist, no blocklist, max risk 1.0, all action types allowed, no session limit, unregistered tools allowed.
Sourcepub fn permissive(id: &str, name: &str) -> Self
pub fn permissive(id: &str, name: &str) -> Self
Create a permissive policy that allows everything in audit mode.
All actions are allowed; violations are only logged as findings.
Sourcepub fn restrictive(id: &str, name: &str) -> Self
pub fn restrictive(id: &str, name: &str) -> Self
Create a restrictive policy that denies by default.
Requires explicit allowlist, blocks unregistered tools, and enforces a conservative risk threshold of 0.7.
Sourcepub fn with_mode(self, mode: EnforcementMode) -> Self
pub fn with_mode(self, mode: EnforcementMode) -> Self
Set the enforcement mode.
Sourcepub fn with_allowed_tools(self, tools: HashSet<String>) -> Self
pub fn with_allowed_tools(self, tools: HashSet<String>) -> Self
Set the allowed tool IDs. Only these tools will be permitted.
Sourcepub fn with_blocked_tools(self, tools: HashSet<String>) -> Self
pub fn with_blocked_tools(self, tools: HashSet<String>) -> Self
Set the blocked tool IDs. These tools are always denied.
Sourcepub fn with_max_risk_score(self, score: f64) -> Self
pub fn with_max_risk_score(self, score: f64) -> Self
Set the maximum risk score allowed.
Sourcepub fn with_allowed_action_types(self, types: HashSet<AgentActionType>) -> Self
pub fn with_allowed_action_types(self, types: HashSet<AgentActionType>) -> Self
Set the allowed action types.
Sourcepub fn with_max_actions_per_session(self, max: u32) -> Self
pub fn with_max_actions_per_session(self, max: u32) -> Self
Set the maximum actions per session.
Sourcepub fn with_allow_unregistered(self, allow: bool) -> Self
pub fn with_allow_unregistered(self, allow: bool) -> Self
Set whether unregistered tools are allowed.
Sourcepub fn evaluate(
&self,
action: &AgentAction,
tool_def: Option<&ToolDefinition>,
) -> PolicyDecision
pub fn evaluate( &self, action: &AgentAction, tool_def: Option<&ToolDefinition>, ) -> PolicyDecision
Evaluate an action against this policy.
Returns a PolicyDecision indicating whether the action is allowed,
denied, or warned, along with any SecurityFindings.
Trait Implementations§
Source§impl Clone for ActionPolicy
impl Clone for ActionPolicy
Source§fn clone(&self) -> ActionPolicy
fn clone(&self) -> ActionPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more