Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix agent not stopping: consecutive_failures counter was resetting on multi-action error steps
Laith Weinbergere1e170a5fdb0
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 72a2b9acd..ceaa70429 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -1185,8 +1185,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):# Record executed actions for loop detectionself._update_loop_detector_actions()- # check for action errors and len more than 1- if self.state.last_result and len(self.state.last_result) == 1 and self.state.last_result[-1].error:+ # check for action errors - increment on any step where the last result has an error+ if self.state.last_result and self.state.last_result[-1].error:self.state.consecutive_failures += 1self.logger.debug(f'🔄 Step {self.state.n_steps}: Consecutive failures: {self.state.consecutive_failures}')return