@@ -64,7 +64,7 @@ impl std::fmt::Display for StopReason {
6464/// conds.increment_turn();
6565/// assert_eq!(conds.should_stop(), Some(StopReason::MaxTurns(3)));
6666/// ```
67- #[ derive( Debug , Clone ) ]
67+ #[ derive( Debug , Clone , Default ) ]
6868pub struct StopConditions {
6969 /// Maximum number of turns before stopping. `None` = unlimited.
7070 pub max_turns : Option < u32 > ,
@@ -84,15 +84,15 @@ impl StopConditions {
8484 /// 2. Token budget exceeded
8585 #[ must_use]
8686 pub fn should_stop ( & self ) -> Option < StopReason > {
87- if let Some ( max) = self . max_turns {
88- if self . current_turn >= max {
89- return Some ( StopReason :: MaxTurns ( max ) ) ;
90- }
87+ if let Some ( max) = self . max_turns
88+ && self . current_turn >= max
89+ {
90+ return Some ( StopReason :: MaxTurns ( max ) ) ;
9191 }
92- if let Some ( max) = self . max_tokens {
93- if self . tokens_used >= max {
94- return Some ( StopReason :: TokenBudgetExceeded ) ;
95- }
92+ if let Some ( max) = self . max_tokens
93+ && self . tokens_used >= max
94+ {
95+ return Some ( StopReason :: TokenBudgetExceeded ) ;
9696 }
9797 None
9898 }
@@ -108,17 +108,6 @@ impl StopConditions {
108108 }
109109}
110110
111- impl Default for StopConditions {
112- fn default ( ) -> Self {
113- Self {
114- max_turns : None ,
115- max_tokens : None ,
116- current_turn : 0 ,
117- tokens_used : 0 ,
118- }
119- }
120- }
121-
122111// ─── Tests ─────────────────────────────────────────────────────────────
123112
124113#[ cfg( test) ]
0 commit comments