pub struct LoopHooks { /* private fields */ }Expand description
The hooks a runtime runs, in registration order.
Empty by default: an agent with no hooks behaves exactly as it did before this module existed, which is what makes the surface safe to add.
Implementations§
Source§impl LoopHooks
impl LoopHooks
pub fn new(hooks: Vec<Arc<dyn LoopHook>>) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub async fn run_start(&self, ev: RunStart<'_>) -> Option<String>
pub async fn run_start(&self, ev: RunStart<'_>) -> Option<String>
Some(reason) when a hook stopped the run before it started.
Sourcepub async fn completion_call(
&self,
session: &str,
turn: usize,
messages: &[Message],
tools: &[ToolSpec],
) -> Result<RequestPatch, String>
pub async fn completion_call( &self, session: &str, turn: usize, messages: &[Message], tools: &[ToolSpec], ) -> Result<RequestPatch, String>
The merged patch for this turn, or the reason the run stopped.
Stops end the chain: a later hook is not consulted about a turn that will not happen.
pub async fn model_turn_finished( &self, session: &str, turn: usize, reply: &Message, ) -> TurnAction
Sourcepub async fn dispatch(
&self,
session: &str,
tool: &str,
arguments: &str,
) -> Result<Option<DispatchRepair>, String>
pub async fn dispatch( &self, session: &str, tool: &str, arguments: &str, ) -> Result<Option<DispatchRepair>, String>
Ok(Some(repair)) when a hook rewrote the call, Ok(None) to let it go as-is,
Err(reason) to stop the run. The first real instruction wins, like the other events.
pub async fn outcome( &self, session: &str, tool: &str, output: &str, is_error: bool, malformed: bool, ) -> OutcomeAction
pub async fn run_settled(&self, ev: Settled<'_>)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LoopHooks
impl !UnwindSafe for LoopHooks
impl Forget for LoopHooks
impl Freeze for LoopHooks
impl Move for LoopHooks
impl Send for LoopHooks
impl Sync for LoopHooks
impl Unpin for LoopHooks
impl UnsafeUnpin for LoopHooks
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