Skip to main content

ToolEventSink

Trait ToolEventSink 

Source
pub trait ToolEventSink: Send + Sync {
    // Required methods
    fn tool_started<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        call_id: &'life1 str,
        tool: &'life2 str,
        args_preview: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn tool_finished<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        call_id: &'life1 str,
        tool: &'life2 str,
        success: bool,
        result_preview: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn tool_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        call_id: &'life1 str,
        tool: &'life2 str,
        error: &'life3 str,
    ) -> 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

Observes tool dispatch lifecycle events from an AgentLoop run.

Why: The only way to make an agent loop’s tool activity observable to an external subscriber (a session.attached client) without forking the loop or the tool registry. What: Three hooks, one per #2055 taxonomy kind; call_id is the ToolCall::id the model assigned, correlating start/finish/error for the same invocation. All are &self (not &mut self) so a sink can be shared as Arc<dyn ToolEventSink> across a PM loop and every delegated sub-agent loop. Test: crate::task::sink::tests::*.

Required Methods§

Source

fn tool_started<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, call_id: &'life1 str, tool: &'life2 str, args_preview: &'life3 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

A tool invocation is about to run.

Source

fn tool_finished<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, call_id: &'life1 str, tool: &'life2 str, success: bool, result_preview: &'life3 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

A tool invocation completed (successfully or with a recoverable error — success distinguishes the two). Use Self::tool_error instead for an exceptional (non-recoverable) failure.

Source

fn tool_error<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, call_id: &'life1 str, tool: &'life2 str, error: &'life3 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

A tool invocation raised an exceptional (non-recoverable) error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§