pub trait AgentHook: Send + Sync {
// Required methods
fn point(&self) -> AgentHookPoint;
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
point: AgentHookPoint,
payload: &'life1 HookPayload,
session: &'life2 Session,
) -> Pin<Box<dyn Future<Output = HookResult> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
// Provided methods
fn matches(&self, _payload: &HookPayload) -> bool { ... }
fn priority(&self) -> u32 { ... }
fn name(&self) -> &str { ... }
}Expand description
Trait for agent lifecycle hooks.
Implementations must be Send + Sync because hooks may be invoked
from multiple concurrent agent runs.
Required Methods§
Sourcefn point(&self) -> AgentHookPoint
fn point(&self) -> AgentHookPoint
Which hook point this hook subscribes to.
Sourcefn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
point: AgentHookPoint,
payload: &'life1 HookPayload,
session: &'life2 Session,
) -> Pin<Box<dyn Future<Output = HookResult> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
point: AgentHookPoint,
payload: &'life1 HookPayload,
session: &'life2 Session,
) -> Pin<Box<dyn Future<Output = HookResult> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Execute the hook.
Receives immutable access to the session, the current hook point, and a
point-specific payload.
Returns a HookResult to control flow.
Provided Methods§
Sourcefn matches(&self, _payload: &HookPayload) -> bool
fn matches(&self, _payload: &HookPayload) -> bool
Whether this hook applies to the point-specific payload.
The default accepts every payload. Configured tool hooks override this to apply their tool-name matcher without spawning a process or emitting a misleading execution checkpoint for non-matching calls.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".