pub struct SleepRefusalHooks;Expand description
ROOT-ONLY guard: refuses a bare sleep (a polling wait) issued by the
workflow orchestrator. A worker’s report lands as a Wake only once the
root ENDS its turn, so a sleep blocks the very message it is waiting for.
Mirrors BashRiskHooks — stateless, a unit struct is the whole type.
Implementations§
Trait Implementations§
Source§impl Default for SleepRefusalHooks
impl Default for SleepRefusalHooks
Source§impl Hooks for SleepRefusalHooks
impl Hooks for SleepRefusalHooks
Source§fn before_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
call: &'life1 ToolCall,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
call: &'life1 ToolCall,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Some(reason) iff this is a bash call whose first non-empty
scan_segments segment leads with sleep; None (allow) otherwise.
A missing / non-string command => allow (the same extraction as
ReadOnlyHooks / BashRiskHooks).
Source§fn transform_tool_input<'life0, 'life1, 'async_trait>(
&'life0 self,
_call: &'life1 mut ToolCall,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn transform_tool_input<'life0, 'life1, 'async_trait>(
&'life0 self,
_call: &'life1 mut ToolCall,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
May mutate the tool call’s arguments before it is executed (e.g. to
rewrite a bash command through
rtk). Mutations are what actually
executes, so before_tool_call/after_tool_call observe the rewrite.Source§fn after_tool_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_call: &'life1 ToolCall,
_out: &'life2 mut ToolOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after_tool_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_call: &'life1 ToolCall,
_out: &'life2 mut ToolOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Runs after every tool execution; may mutate the output before it is
recorded and sent to the LLM.
Source§fn before_inbound<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_from: Option<&'life1 SessionId>,
_request: &'life2 mut Request,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before_inbound<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_from: Option<&'life1 SessionId>,
_request: &'life2 mut Request,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Policy for an inbound peer message (an A2A
Notify/Interrupt/Wake):
the mirror of Hooks::before_tool_call. May rewrite the request in
place (the rewrite is what is delivered); Some(reason) drops it — the
reason is returned to the sender when it is an ask. A message dropped
here never reaches the context or starts a turn.Source§fn transform_context<'life0, 'life1, 'async_trait>(
&'life0 self,
_msgs: &'life1 mut Vec<AgentMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn transform_context<'life0, 'life1, 'async_trait>(
&'life0 self,
_msgs: &'life1 mut Vec<AgentMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Runs at every turn start, after steering is drained, before streaming.
Source§fn should_stop_after_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 [AgentMessage],
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn should_stop_after_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 [AgentMessage],
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Checked after tool execution completes; true ends the run with
StopReason::Stop.
Source§fn after_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 [AgentMessage],
_stop: StopReason,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_run<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 [AgentMessage],
_stop: StopReason,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Runs once when a
run finishes, with the final context and why it
stopped. The A2A auto-report rides this (a worker forwards its result to
its orchestrator); a no-op by default.Auto Trait Implementations§
impl Freeze for SleepRefusalHooks
impl RefUnwindSafe for SleepRefusalHooks
impl Send for SleepRefusalHooks
impl Sync for SleepRefusalHooks
impl Unpin for SleepRefusalHooks
impl UnsafeUnpin for SleepRefusalHooks
impl UnwindSafe for SleepRefusalHooks
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