pub trait ToolDispatchHook: Send + Sync {
// Provided methods
fn before_invocation<'life0, 'life1, 'async_trait>(
&'life0 self,
_invocation: &'life1 ToolInvocation,
) -> Pin<Box<dyn Future<Output = Result<ToolDispatchAction, KernelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_invocation<'life0, 'life1, 'async_trait>(
&'life0 self,
_result: &'life1 ToolInvocationResult,
) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_invocation_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_invocation: &'life1 ToolInvocation,
_error: &'life2 KernelError,
) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Hook for policy, accounting, and tracing around normalized tool dispatch.
Hooks are intentionally provider-neutral: they see only the normalized
ToolInvocation and the resulting ToolInvocationResult. Concrete
policy engines, approval systems, and trace exporters should live in
downstream crates and plug into this small kernel surface.
Provided Methods§
Sourcefn before_invocation<'life0, 'life1, 'async_trait>(
&'life0 self,
_invocation: &'life1 ToolInvocation,
) -> Pin<Box<dyn Future<Output = Result<ToolDispatchAction, KernelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_invocation<'life0, 'life1, 'async_trait>(
&'life0 self,
_invocation: &'life1 ToolInvocation,
) -> Pin<Box<dyn Future<Output = Result<ToolDispatchAction, KernelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before each invocation. Return ToolDispatchAction::Continue
to invoke the tool, ToolDispatchAction::Skip to synthesize a result,
or ToolDispatchAction::Terminate to stop the dispatch loop.
Sourcefn after_invocation<'life0, 'life1, 'async_trait>(
&'life0 self,
_result: &'life1 ToolInvocationResult,
) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_invocation<'life0, 'life1, 'async_trait>(
&'life0 self,
_result: &'life1 ToolInvocationResult,
) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after a tool invocation or hook-provided skip result is recorded.
Sourcefn on_invocation_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_invocation: &'life1 ToolInvocation,
_error: &'life2 KernelError,
) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_invocation_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_invocation: &'life1 ToolInvocation,
_error: &'life2 KernelError,
) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when dispatch stops after this hook may have observed the
invocation in Self::before_invocation. Hooks that reserve resources
before dispatch should release them here.