Skip to content

Commit

Permalink
Not stopping while running
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr committed Nov 25, 2024
1 parent 9b7af2b commit 301a63d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion openhands/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ async def start_step_loop(self):
"""The main loop for the agent's step-by-step execution."""

self.log('info', 'Starting step loop...')
while should_continue():
while True:
if not self._is_awaiting_observation() and not should_continue():
break
if self._closed:
break
try:
Expand Down Expand Up @@ -903,3 +905,11 @@ def __repr__(self):
f'state={self.state!r}, agent_task={self.agent_task!r}, '
f'delegate={self.delegate!r}, _pending_action={self._pending_action!r})'
)

def _is_awaiting_observation(self):
events = self.event_stream.get_events(reverse=True)
for event in events:
if isinstance(event, AgentStateChangedObservation):
result = event.agent_state == AgentState.RUNNING
return result
return False

0 comments on commit 301a63d

Please sign in to comment.