Skip to main content

AgentLoopCallback

Trait AgentLoopCallback 

Source
pub trait AgentLoopCallback: Send + Sync {
    // Required methods
    fn before_iteration<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 SessionId,
        iteration: i32,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn after_iteration<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session_id: &'life1 SessionId,
        iteration: i32,
        result: &'life2 IterationResult,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn before_tool_call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session_id: &'life1 SessionId,
        tool_call: &'life2 ToolCall,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn after_tool_call<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        session_id: &'life1 SessionId,
        tool_call: &'life2 ToolCall,
        result: &'life3 ToolResult,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Agent 执行循环回调接口

用于在执行过程中注入自定义逻辑。

Required Methods§

Source

fn before_iteration<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, iteration: i32, ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

在每次迭代前调用

Source

fn after_iteration<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, iteration: i32, result: &'life2 IterationResult, ) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

在每次迭代后调用

Source

fn before_tool_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, tool_call: &'life2 ToolCall, ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

在工具调用前调用

Source

fn after_tool_call<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, tool_call: &'life2 ToolCall, result: &'life3 ToolResult, ) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

在工具调用后调用

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§