pub trait ToolPreHook: Send + Sync {
// Required method
fn before_execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_use: &'life1 ToolUse,
context: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<PreHookDecision>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Pluggable pre-execution hook for semantic tool validation.
Implement this to intercept tool calls before execution and validate
call intent against current agent state (not just JSON schema).
Hook is set via AgentContext::with_pre_execute_hook().
Required Methods§
Sourcefn before_execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_use: &'life1 ToolUse,
context: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<PreHookDecision>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before_execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_use: &'life1 ToolUse,
context: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<PreHookDecision>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before tool execution to validate or reject the call.