Skip to content

Commit

Permalink
minor fixes for when commands time out (#5518)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren authored Dec 10, 2024
1 parent a482182 commit 5fa1851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions openhands/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def update_state_before_step(self):
self.state.local_iteration += 1

async def update_state_after_step(self):
# update metrics especially for cost. Use deepcopy to avoid it being modified by agent.reset()
# update metrics especially for cost. Use deepcopy to avoid it being modified by agent._reset()
self.state.local_metrics = copy.deepcopy(self.agent.llm.metrics)

async def _react_to_exception(
Expand Down Expand Up @@ -317,9 +317,10 @@ async def _handle_message_action(self, action: MessageAction) -> None:
elif action.source == EventSource.AGENT and action.wait_for_response:
await self.set_agent_state_to(AgentState.AWAITING_USER_INPUT)

def reset_task(self) -> None:
"""Resets the agent's task."""
def _reset(self) -> None:
"""Resets the agent controller"""
self.almost_stuck = 0
self._pending_action = None
self.agent.reset()

async def set_agent_state_to(self, new_state: AgentState) -> None:
Expand All @@ -337,7 +338,7 @@ async def set_agent_state_to(self, new_state: AgentState) -> None:
return

if new_state in (AgentState.STOPPED, AgentState.ERROR):
self.reset_task()
self._reset()
elif (
new_state == AgentState.RUNNING
and self.state.agent_state == AgentState.PAUSED
Expand Down
2 changes: 1 addition & 1 deletion openhands/runtime/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def send_request(
timeout: int = 10,
**kwargs: Any,
) -> requests.Response:
response = session.request(method, url, **kwargs)
response = session.request(method, url, timeout=timeout, **kwargs)
try:
response.raise_for_status()
except requests.HTTPError as e:
Expand Down

0 comments on commit 5fa1851

Please sign in to comment.