π OpenHands: AI-Driven Development
Fix: Bump max_iterations when resuming due to throttling (#3410)
tofarrf5aa111ba6ab
diff --git a/openhands/controller/agent_controller.py b/openhands/controller/agent_controller.pyindex 39cebd5355..9f626080ec 100644--- a/openhands/controller/agent_controller.py+++ b/openhands/controller/agent_controller.py@@ -108,6 +108,8 @@ class AgentController:self.max_budget_per_task = max_budget_per_taskself.agent_to_llm_config = agent_to_llm_config if agent_to_llm_config else {}self.agent_configs = agent_configs if agent_configs else {}+ self._initial_max_iterations = max_iterations+ self._initial_max_budget_per_task = max_budget_per_task# stuck helperself._stuck_detector = StuckDetector(self.state)@@ -245,6 +247,21 @@ class AgentController:):# user intends to interrupt traffic control and let the task resume temporarilyself.state.traffic_control_state = TrafficControlState.PAUSED+ # User has chosen to deliberately continue - lets double the max iterations+ if (+ self.state.iteration is not None+ and self.state.max_iterations is not None+ and self._initial_max_iterations is not None+ ):+ if self.state.iteration >= self.state.max_iterations:+ self.state.max_iterations += self._initial_max_iterations+ if (+ self.state.metrics.accumulated_cost is not None+ and self.max_budget_per_task is not None+ and self._initial_max_budget_per_task is not None+ ):+ if self.state.metrics.accumulated_cost >= self.max_budget_per_task:+ self.max_budget_per_task += self._initial_max_budget_per_taskself.state.agent_state = new_stateif new_state == AgentState.STOPPED or new_state == AgentState.ERROR: