Skip to content

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

Fix first-step detection in take_step by updating condition to check for step_info.step_number == 0. This change ensures that initial actions are executed correctly on the actual first step.

Magnus Müller2a1f820d1bd9
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index a12636f1d..2a46efc12 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1312,7 +1312,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
Returns:
Tuple[bool, bool]: (is_done, is_valid)
"""
- if step_info is not None and step_info.step_number == 1:
+ if step_info is not None and step_info.step_number == 0:
# First step
self._log_first_step_startup()
await self._execute_initial_actions()