Skip to main content

CanUseToolCallback

Type Alias CanUseToolCallback 

Source
pub type CanUseToolCallback = Arc<dyn Fn(String, Value, ToolPermissionContext) -> BoxFuture<'static, Result<PermissionResult, Error>> + Send + Sync>;
Expand description

Callback type for custom tool permission logic.

This function is invoked before each tool execution, receiving:

  • tool_name (String) — The name of the tool being called.
  • input_data (Value) — The tool’s input parameters.
  • context (ToolPermissionContext) — Additional context including permission suggestions.

Returns a PermissionResult indicating whether the tool call should be allowed or denied.

§Note

When using can_use_tool, the prompt must be provided as streaming messages (not a plain text string), and permission_prompt_tool_name must not be set.

Aliased Type§

pub struct CanUseToolCallback { /* private fields */ }