File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,9 +207,22 @@ def _execute_control_loop(self) -> None:
207207 self ._step_index = 0
208208 continue_execution = True
209209 while continue_execution :
210+ if self ._is_max_steps_reached ():
211+ break
210212 continue_execution = self ._execute_step ()
211213 self ._on_control_loop_end ()
212214
215+ def _is_max_steps_reached (self ) -> bool :
216+ if self .settings .max_steps is None :
217+ return False
218+ if self ._step_index >= self .settings .max_steps :
219+ logger .info (
220+ "Reached max_steps limit (%d), stopping conversation" ,
221+ self .settings .max_steps ,
222+ )
223+ return True
224+ return False
225+
213226 @tracer .start_as_current_span ("_teardown_control_loop" )
214227 def _teardown_control_loop (self ) -> None :
215228 # Finish recording if cache_manager is active and not executing from cache
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ class ActSettings(BaseModel):
8989 model_config = ConfigDict (arbitrary_types_allowed = True )
9090
9191 messages : MessageSettings = Field (default_factory = MessageSettings )
92+ max_steps : int | None = None
9293
9394
9495class GetSettings (BaseModel ):
You can’t perform that action at this time.
0 commit comments