pub trait AgentHook: Send + Sync {
// Provided methods
fn before_agent_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
prompt: String,
resources: Vec<Resource>,
) -> Pin<Box<dyn Future<Output = Result<(String, Vec<Resource>), BoxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn after_agent_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
output: AgentOutput,
) -> Pin<Box<dyn Future<Output = Result<AgentOutput, BoxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_background_start<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: &'life2 str,
_req: &'life3 CompletionRequest,
) -> 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 on_background_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: String,
_progress: AgentOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_background_end<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: String,
_output: AgentOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Typed hook for nested agent calls and agent-runner extensions.
Provided Methods§
Sourcefn before_agent_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
prompt: String,
resources: Vec<Resource>,
) -> Pin<Box<dyn Future<Output = Result<(String, Vec<Resource>), BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_agent_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
prompt: String,
resources: Vec<Resource>,
) -> Pin<Box<dyn Future<Output = Result<(String, Vec<Resource>), BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before an agent is executed, allowing you to modify the prompt and resources.
Sourcefn after_agent_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
output: AgentOutput,
) -> Pin<Box<dyn Future<Output = Result<AgentOutput, BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_agent_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
output: AgentOutput,
) -> Pin<Box<dyn Future<Output = Result<AgentOutput, BoxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after an agent is executed, allowing you to modify the output.
For background execution, implementations can use
AgentHook::on_background_end to observe the final result.
Sourcefn on_background_start<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: &'life2 str,
_req: &'life3 CompletionRequest,
) -> 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 on_background_start<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: &'life2 str,
_req: &'life3 CompletionRequest,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called when an agent starts in the background. The session ID can be used to correlate progress and final output hooks.
Sourcefn on_background_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: String,
_progress: AgentOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_background_progress<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: String,
_progress: AgentOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when an agent reports progress from a background task.
Sourcefn on_background_end<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: String,
_output: AgentOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_background_end<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 AgentCtx,
_session_id: String,
_output: AgentOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called with the final output from a background agent task.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".