Skip to main content

ToolHook

Trait ToolHook 

Source
pub trait ToolHook: Send + Sync {
    // Required method
    fn before_tool_use<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tool_name: &'life1 str,
        arguments: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = HookDecision> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn after_tool_result<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _tool_name: &'life1 str,
        _arguments: &'life2 str,
        _result: &'life3 ToolResult,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

Hook that runs before and after every tool execution.

Required Methods§

Source

fn before_tool_use<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tool_name: &'life1 str, arguments: &'life2 str, ) -> Pin<Box<dyn Future<Output = HookDecision> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called before the tool executes. Return Block to skip execution.

Provided Methods§

Source

fn after_tool_result<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _tool_name: &'life1 str, _arguments: &'life2 str, _result: &'life3 ToolResult, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Called after the tool completes (whether success or error).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§