Skip to main content

Hook

Trait Hook 

Source
pub trait Hook: Send + Sync {
    // Provided methods
    fn on_agent_start<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 AgentCtx,
        _agent: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn on_agent_end<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 AgentCtx,
        _agent: &'life2 str,
        output: AgentOutput,
    ) -> Pin<Box<dyn Future<Output = Result<AgentOutput, BoxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn on_tool_start<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 BaseCtx,
        _tool: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn on_tool_end<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 BaseCtx,
        _tool: &'life2 str,
        output: ToolOutput<Json>,
    ) -> Pin<Box<dyn Future<Output = Result<ToolOutput<Json>, BoxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Engine-level hook for agent runs and direct tool calls.

Returning an error from a start hook aborts execution. End hooks may inspect or replace the output before it is returned to the caller.

Provided Methods§

Source

fn on_agent_start<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _ctx: &'life1 AgentCtx, _agent: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called before an agent is executed.

Source

fn on_agent_end<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _ctx: &'life1 AgentCtx, _agent: &'life2 str, output: AgentOutput, ) -> Pin<Box<dyn Future<Output = Result<AgentOutput, BoxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called after an agent is executed.

Source

fn on_tool_start<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _ctx: &'life1 BaseCtx, _tool: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), BoxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called before a tool is called.

Source

fn on_tool_end<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _ctx: &'life1 BaseCtx, _tool: &'life2 str, output: ToolOutput<Json>, ) -> Pin<Box<dyn Future<Output = Result<ToolOutput<Json>, BoxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called after a tool is called.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§