Skip to content

Commit f3183f9

Browse files
feat: add max_steps parameter to ActSettings
1 parent 057810b commit f3183f9

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/askui/models/shared/conversation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/askui/models/shared/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

9495
class GetSettings(BaseModel):

0 commit comments

Comments
 (0)