Skip to main content

ReactLoopGuard

Trait ReactLoopGuard 

Source
pub trait ReactLoopGuard: Send + Sync {
    // Required methods
    fn on_reasoning_only<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 GuardCtx,
    ) -> Pin<Box<dyn Future<Output = GuardAction> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_empty_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 GuardCtx,
    ) -> Pin<Box<dyn Future<Output = GuardAction> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_text_only<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 GuardCtx,
    ) -> Pin<Box<dyn Future<Output = GuardAction> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

React Loop Guard trait

Each method corresponds to an abnormal branch, returns GuardAction to decide next step. Implementors can:

  • Use Focus for intelligent judgment
  • Use counters + thresholds
  • Pass through or intercept directly

Required Methods§

Source

fn on_reasoning_only<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 GuardCtx, ) -> Pin<Box<dyn Future<Output = GuardAction> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Model returns only reasoning, no text/tool call

Source

fn on_empty_response<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 GuardCtx, ) -> Pin<Box<dyn Future<Output = GuardAction> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Model returns empty (no text, no reasoning, no tool call)

Source

fn on_text_only<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 GuardCtx, ) -> Pin<Box<dyn Future<Output = GuardAction> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Model returns text-only (no tool call)

Note: This method is called after middleware. If middleware has set follow_up_message, this branch won’t be entered.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§