pub struct HookStack<M>where
M: CompletionModel,{ /* private fields */ }Expand description
An ordered list of hooks run as one hook.
Each hook is consulted in registration order. How their Flow results
combine depends on the event (see the module docs):
CompletionCall patches accumulate;
ToolCall / ToolResult
rewrites chain; every other event uses first non-Continue
wins. Because the runner is fail-closed, a non-Continue action always
takes effect or terminates the run — it is never silently ignored. An empty
stack is the no-op hook and observes nothing, so the
runner skips event dispatch for it entirely.
This is the default hook type carried by an
Agent and an
AgentRunner; build one with
add_hook.
Implementations§
Trait Implementations§
Source§impl<M> AgentHook<M> for HookStack<M>where
M: CompletionModel,
impl<M> AgentHook<M> for HookStack<M>where
M: CompletionModel,
Source§fn observes(&self, kind: StepEventKind) -> bool
fn observes(&self, kind: StepEventKind) -> bool
The stack observes an event kind if any of its hooks does (so an empty stack observes nothing).
Source§async fn on_event(&self, ctx: &HookContext, event: StepEvent<'_, M>) -> Flow
async fn on_event(&self, ctx: &HookContext, event: StepEvent<'_, M>) -> Flow
Called at every observable point of the agent run (subject to
observes). Receives the run-scoped HookContext and
the StepEvent. The default implementation is a no-op: it ignores every
event and returns Flow::Continue. It does not narrow
observes (which defaults to true), so a hook that
takes this default is still dispatched every event — override observes
to skip the high-frequency delta events. (The () no-op hook overrides
observes to false, so the runner skips dispatching those delta events
to it; it still receives, and returns Flow::Continue for, every other
event.)Source§impl<M> Clone for HookStack<M>where
M: CompletionModel,
impl<M> Clone for HookStack<M>where
M: CompletionModel,
Source§impl<M> Debug for HookStack<M>where
M: CompletionModel,
impl<M> Debug for HookStack<M>where
M: CompletionModel,
Auto Trait Implementations§
impl<M> !RefUnwindSafe for HookStack<M>
impl<M> !UnwindSafe for HookStack<M>
impl<M> Freeze for HookStack<M>
impl<M> Send for HookStack<M>
impl<M> Sync for HookStack<M>
impl<M> Unpin for HookStack<M>
impl<M> UnsafeUnpin for HookStack<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
impl<T> DebuggableStorage for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more