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
create _execute_initial_actions
Magnus Müllere1f95ca574e5
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 144d946a7..b2007c552 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -1252,15 +1252,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):else:self.logger.warning('⚠️ No browser focus established, may cause navigation issues')- # Execute initial actions if provided- if self.initial_actions and not self.state.follow_up_task:- self.logger.debug(f'⚡ Executing {len(self.initial_actions)} initial actions...')- result = await self.multi_act(self.initial_actions, check_for_new_elements=False)- # update result 1 to mention that its was automatically loaded- if result and self.initial_url and result[0].long_term_memory:- result[0].long_term_memory = f'Found initial url and automatically loaded it. {result[0].long_term_memory}'- self.state.last_result = result- self.logger.debug('Initial actions completed')+ await self._execute_initial_actions()self.logger.debug(f'🔄 Starting main execution loop with max {max_steps} steps...')for step in range(max_steps):@@ -1636,6 +1628,17 @@ class Agent(Generic[Context, AgentStructuredOutput]):return results+ async def _execute_initial_actions(self) -> None:+ # Execute initial actions if provided+ if self.initial_actions and not self.state.follow_up_task:+ self.logger.debug(f'⚡ Executing {len(self.initial_actions)} initial actions...')+ result = await self.multi_act(self.initial_actions, check_for_new_elements=False)+ # update result 1 to mention that its was automatically loaded+ if result and self.initial_url and result[0].long_term_memory:+ result[0].long_term_memory = f'Found initial url and automatically loaded it. {result[0].long_term_memory}'+ self.state.last_result = result+ self.logger.debug('Initial actions completed')+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'