Skip to content

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

wait before execution in execute_history_step

Saurav Pandac5d763a8dd39
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index c5f3fb724..81f8fe577 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -2284,6 +2284,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):
async def _execute_history_step(self, history_item: AgentHistory, delay: float) -> list[ActionResult]:
"""Execute a single step from history with element validation"""
assert self.browser_session is not None, 'BrowserSession is not set up'
+
+ await asyncio.sleep(delay)
state = await self.browser_session.get_browser_state_summary(include_screenshot=False)
if not state or not history_item.model_output:
raise ValueError('Invalid state or model output')
@@ -2300,8 +2302,6 @@ class Agent(Generic[Context, AgentStructuredOutput]):
raise ValueError(f'Could not find matching element {i} in current page')
result = await self.multi_act(updated_actions)
-
- await asyncio.sleep(delay)
return result
async def _update_action_indices(