Skip to content

Commit

Permalink
Fix: Reset iteration count when resuming due to throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim O'Farrell committed Aug 15, 2024
1 parent c67df47 commit 980d798
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions opendevin/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ async def _start_step_loop(self):

async def on_event(self, event: Event):
if isinstance(event, ChangeAgentStateAction):
# Reset here....
await self.set_agent_state_to(event.agent_state) # type: ignore
elif isinstance(event, MessageAction):
if event.source == EventSource.USER:
Expand Down Expand Up @@ -225,6 +226,8 @@ async def set_agent_state_to(self, new_state: AgentState):
):
# user intends to interrupt traffic control and let the task resume temporarily
self.state.traffic_control_state = TrafficControlState.PAUSED
# Reset the iterations (So user will not be immediately asked again)
self.state.iteration = 0

self.state.agent_state = new_state
if new_state == AgentState.STOPPED or new_state == AgentState.ERROR:
Expand Down Expand Up @@ -349,6 +352,7 @@ async def _step(self) -> None:
extra={'msg_type': 'STEP'},
)

print(f"TRACE:agent_controller#_step:102:#{self.state.iteration}:#{self.state.max_iterations}")
if self.state.iteration >= self.state.max_iterations:
if self.state.traffic_control_state == TrafficControlState.PAUSED:
logger.info(
Expand Down

0 comments on commit 980d798

Please sign in to comment.