pub struct LoopGuard { /* private fields */ }Expand description
Safety net that guarantees turn termination by tracking steps,
tool calls, consecutive errors, and elapsed time against TurnPolicy limits.
Implementations§
Source§impl LoopGuard
impl LoopGuard
Sourcepub fn new(policy: TurnPolicy) -> Self
pub fn new(policy: TurnPolicy) -> Self
Create a new guard tied to the given policy.
Sourcepub fn can_continue(&self) -> bool
pub fn can_continue(&self) -> bool
Returns true if the turn may continue executing.
Sourcepub fn record_step(&mut self)
pub fn record_step(&mut self)
Record one scheduler step.
Sourcepub fn record_tool_call(&mut self)
pub fn record_tool_call(&mut self)
Record one tool call.
Sourcepub fn record_error(&mut self)
pub fn record_error(&mut self)
Record a consecutive error.
Sourcepub fn reset_errors(&mut self)
pub fn reset_errors(&mut self)
Reset the consecutive-error counter (e.g. after a successful call).
Sourcepub fn reason(&self) -> GuardReason
pub fn reason(&self) -> GuardReason
The reason the guard stopped the turn.
Only meaningful when can_continue returns false.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LoopGuard
impl RefUnwindSafe for LoopGuard
impl Send for LoopGuard
impl Sync for LoopGuard
impl Unpin for LoopGuard
impl UnsafeUnpin for LoopGuard
impl UnwindSafe for LoopGuard
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