pub struct HooksSet(/* private fields */);Expand description
Ordered set of hook implementations run at every hook point.
Adding a hook is just pushing another Hooks impl: transform_* and
after_tool_call run for every hook in order, before_tool_call and
should_stop_after_turn short-circuit on the first hit. An empty set is
the default (every hook method is a no-op), so an agent without extra
hooks typically passes HooksSet::default().
Implementations§
Source§impl HooksSet
impl HooksSet
pub fn new() -> Self
Sourcepub fn one(hook: Arc<dyn Hooks>) -> Self
pub fn one(hook: Arc<dyn Hooks>) -> Self
A set with a single hook — the common case for one integration
(e.g. HooksSet::one(Arc::new(RtkHooks::new(rtk)))).
pub fn push(&mut self, hook: Arc<dyn Hooks>)
pub fn is_empty(&self) -> bool
pub async fn transform_tool_input(&self, call: &mut ToolCall)
Sourcepub async fn before_tool_call(&self, call: &ToolCall) -> Option<String>
pub async fn before_tool_call(&self, call: &ToolCall) -> Option<String>
First Some(reason) wins: a blocking hook prevents execution entirely
(and therefore any later after_tool_call).
Sourcepub async fn before_inbound(
&self,
from: Option<&SessionId>,
request: &mut Request,
) -> Option<String>
pub async fn before_inbound( &self, from: Option<&SessionId>, request: &mut Request, ) -> Option<String>
First Some(reason) wins: a dropping hook prevents delivery (the request
is not serviced). request may have been rewritten in place by earlier
hooks — the rewrite is what would be delivered.
pub async fn after_tool_call(&self, call: &ToolCall, out: &mut ToolOutput)
pub async fn transform_context(&self, msgs: &mut Vec<AgentMessage>)
Sourcepub async fn should_stop_after_turn(&self, ctx: &[AgentMessage]) -> bool
pub async fn should_stop_after_turn(&self, ctx: &[AgentMessage]) -> bool
true ends the run; evaluated after the tool loop completes.
Sourcepub async fn after_run(&self, ctx: &[AgentMessage], stop: StopReason)
pub async fn after_run(&self, ctx: &[AgentMessage], stop: StopReason)
Runs every hook’s after_run in order, once per run.