pub enum TerminationReason {
Complete,
StopCondition {
reason: Option<String>,
},
MaxIterations {
limit: u32,
},
LoopDetected {
tool_name: String,
count: u32,
},
Timeout {
limit: Duration,
},
}Expand description
Why a tool loop terminated.
Used for observability and debugging. Each variant captures specific information about why the loop ended.
§Example
use llm_stack_core::tool::TerminationReason;
use std::time::Duration;
match reason {
TerminationReason::Complete => println!("Task completed naturally"),
TerminationReason::StopCondition { reason } => {
println!("Custom stop: {}", reason.as_deref().unwrap_or("no reason"));
}
TerminationReason::MaxIterations { limit } => {
println!("Hit iteration limit: {limit}");
}
TerminationReason::LoopDetected { tool_name, count } => {
println!("Stuck calling {tool_name} {count} times");
}
TerminationReason::Timeout { limit } => {
println!("Exceeded timeout: {limit:?}");
}
}Variants§
Complete
LLM returned a response with no tool calls (natural completion).
StopCondition
Custom stop condition returned StopDecision::Stop or
StopDecision::StopWithReason.
Fields
§
reason: Option<String>The reason provided via StopDecision::StopWithReason, if any.
MaxIterations
Hit the max_iterations limit.
LoopDetected
Loop detection triggered with LoopAction::Stop.
Fields
Timeout
Wall-clock timeout exceeded.
Trait Implementations§
Source§impl Clone for TerminationReason
impl Clone for TerminationReason
Source§fn clone(&self) -> TerminationReason
fn clone(&self) -> TerminationReason
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TerminationReason
impl Debug for TerminationReason
Source§impl PartialEq for TerminationReason
impl PartialEq for TerminationReason
impl Eq for TerminationReason
impl StructuralPartialEq for TerminationReason
Auto Trait Implementations§
impl Freeze for TerminationReason
impl RefUnwindSafe for TerminationReason
impl Send for TerminationReason
impl Sync for TerminationReason
impl Unpin for TerminationReason
impl UnwindSafe for TerminationReason
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