pub trait ReactLoopGuard: Send + Sync {
// Required method
fn on_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 GuardCtx,
) -> Pin<Box<dyn Future<Output = GuardDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn on_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 GuardCtx,
) -> Pin<Box<dyn Future<Output = GuardDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn set_notice(&self, _handle: NoticeHandle) { ... }
}Expand description
React Loop Guard trait — single unified entry point.
Runtime builds GuardCtx (with scene hints), guard decides what to do. The guard has full control: it can trust the hints or re-detect.
Required Methods§
Provided Methods§
Sourcefn on_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 GuardCtx,
) -> Pin<Box<dyn Future<Output = GuardDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 GuardCtx,
) -> Pin<Box<dyn Future<Output = GuardDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Callback when model calls a tool (new)
Default implementation: returns Complete (let other logic continue)
Usage:
- DefaultGuard can return RestoreThinking here
- Other guards can record tool call history
Note: This callback is called before tool execution, Guard cannot prevent tool execution
Sourcefn set_notice(&self, _handle: NoticeHandle)
fn set_notice(&self, _handle: NoticeHandle)
Receive the engine’s notice handle (Batch E). Called once by the runtime when the guard is registered, before any run starts. Guards that want to surface display-only notices (e.g. judge degradation) store the handle; the default implementation ignores it, so existing implementers are unaffected.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".