Skip to main content

ToolObserver

Trait ToolObserver 

Source
pub trait ToolObserver: Send + Sync {
    // Required methods
    fn on_tool_start(
        &self,
        tool_name: &str,
        input_summary: &str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
    fn on_tool_complete(
        &self,
        tool_name: &str,
        duration: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
    fn on_tool_error(
        &self,
        tool_name: &str,
        error: &str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
}
Expand description

Observer for tool call lifecycle events.

pe-tools calls these methods around each tool execution. pe-runtime provides a streaming implementation that converts them to StreamEvent.

Injected into NodeContext alongside the stream sender. pe-tools extracts it from NodeContext::tool_observer().

Required Methods§

Source

fn on_tool_start( &self, tool_name: &str, input_summary: &str, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Called before a tool starts executing.

Source

fn on_tool_complete( &self, tool_name: &str, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Called after a tool completes successfully.

Source

fn on_tool_error( &self, tool_name: &str, error: &str, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Called when a tool fails with an error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§