Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Only increase errors if first action fails

Magnus Müller56086329fd39
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 144cb804d..29ad53d5e 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -798,8 +798,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):
# Check for new downloads after executing actions
await self._check_and_update_downloads('after executing actions')
- # check for action errors
- if self.state.last_result and self.state.last_result[-1].error:
+ # 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:
self.state.consecutive_failures += 1
self.logger.debug(f'🔄 Step {self.state.n_steps}: Consecutive failures: {self.state.consecutive_failures}')
return