pub trait ToolHook: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn is_enabled(&self) -> bool;
fn pre_execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<HookResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn post_execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: &'life2 Value,
result: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided methods
fn applies_to(&self) -> Vec<&str> { ... }
fn applies_to_tool(&self, tool_name: &str) -> bool { ... }
}Expand description
Tool execution hook trait
Required Methods§
Sourcefn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Whether this hook is enabled
Sourcefn pre_execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<HookResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn pre_execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<HookResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Pre-execute hook (before tool execution) Returns HookResult to control execution flow
Sourcefn post_execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: &'life2 Value,
result: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn post_execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
params: &'life2 Value,
result: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Post-execute hook (after tool execution) Can modify the result before returning to AI
Provided Methods§
Sourcefn applies_to(&self) -> Vec<&str>
fn applies_to(&self) -> Vec<&str>
Tools this hook applies to (empty = all tools)
Sourcefn applies_to_tool(&self, tool_name: &str) -> bool
fn applies_to_tool(&self, tool_name: &str) -> bool
Check if hook applies to a specific tool
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".