AgentMiddleware

Trait AgentMiddleware 

Source
pub trait AgentMiddleware: Send + Sync {
    // Required methods
    fn id(&self) -> &'static str;
    fn modify_model_request<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 mut MiddlewareContext<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn tools(&self) -> Vec<Arc<dyn ToolHandle>> { ... }
}
Expand description

Middleware hook that can register additional tools and mutate the model request prior to execution. Mirrors the Python AgentMiddleware contracts but keeps the interface async-first for future network calls.

Required Methods§

Source

fn id(&self) -> &'static str

Unique identifier for logging and diagnostics.

Source

fn modify_model_request<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 mut MiddlewareContext<'life2>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Apply middleware-specific mutations to the pending model request.

Provided Methods§

Source

fn tools(&self) -> Vec<Arc<dyn ToolHandle>>

Tools to expose when this middleware is active.

Implementors§