pub trait Plugin:
Send
+ Sync
+ 'static {
Show 13 methods
// Required method
fn name(&self) -> &str;
// Provided methods
fn before_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn before_tool<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn after_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_result: &'life2 Value,
_ctx: &'life3 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn on_event<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_event: &'life1 Event,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_user_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_message: &'life1 str,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn before_model<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 LlmRequest,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn after_model<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_response: &'life1 LlmResponse,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_model_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_error: &'life1 str,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_tool_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_error: &'life2 str,
_ctx: &'life3 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Plugin trait — lifecycle hooks with control-flow capabilities.
Unlike Middleware (which is observe-only), plugins can deny or
short-circuit execution. All hooks default to PluginResult::Continue.
Required Methods§
Provided Methods§
Sourcefn before_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before an agent starts execution.
Sourcefn after_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after an agent completes execution.
Sourcefn before_tool<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before_tool<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before a tool is executed. Return Deny to prevent execution.
Sourcefn after_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_result: &'life2 Value,
_ctx: &'life3 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn after_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_result: &'life2 Value,
_ctx: &'life3 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called after a tool completes. Can transform or deny the result.
Sourcefn on_event<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_event: &'life1 Event,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_event<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_event: &'life1 Event,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when an event is emitted.
Sourcefn on_user_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_message: &'life1 str,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_user_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_message: &'life1 str,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when a user message is received.
Sourcefn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before a run starts (before the agent loop).
Sourcefn after_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after a run completes (after the agent loop).
Sourcefn before_model<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 LlmRequest,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before_model<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 LlmRequest,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before a model generation request.
Sourcefn after_model<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_response: &'life1 LlmResponse,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after_model<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_response: &'life1 LlmResponse,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after a model generation response.
Sourcefn on_model_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_error: &'life1 str,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_model_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_error: &'life1 str,
_ctx: &'life2 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when a model generation fails.
Sourcefn on_tool_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_error: &'life2 str,
_ctx: &'life3 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn on_tool_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_call: &'life1 FunctionCall,
_error: &'life2 str,
_ctx: &'life3 InvocationContext,
) -> Pin<Box<dyn Future<Output = PluginResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called when a tool execution fails.