Skip to main content

PermissionChecker

Trait PermissionChecker 

Source
pub trait PermissionChecker: Send + Sync {
    // Required method
    fn check(&self, tool_name: &str, args: &Value) -> PermissionDecision;

    // Provided methods
    fn snapshot_for_run(&self) -> Option<Arc<dyn PermissionChecker>> { ... }
    fn expose_to_model(&self, _tool_name: &str) -> bool { ... }
}
Expand description

Trait for checking tool execution permissions.

Implement this trait to provide custom permission logic. The built-in PermissionPolicy implements this trait using declarative allow/deny/ask rules with pattern matching.

Required Methods§

Source

fn check(&self, tool_name: &str, args: &Value) -> PermissionDecision

Check whether a tool invocation is allowed, denied, or requires confirmation.

Provided Methods§

Source

fn snapshot_for_run(&self) -> Option<Arc<dyn PermissionChecker>>

Freeze any mutable host policy for one agent run.

Stateless checkers can keep the default and will be shared as-is. Interactive hosts whose policy changes between turns should return an immutable checker here so an in-flight or background child cannot gain or lose authority when the next turn selects a different mode.

Source

fn expose_to_model(&self, _tool_name: &str) -> bool

Whether a tool definition should be exposed to the model.

This controls model-visible capabilities only. Self::check remains the authoritative execution-time decision for any tool invocation. Existing checkers expose every tool unless they explicitly override this method.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§