Skip to content

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

fix: Execute initial actions when rerun history

Sean Guc2b1b98d2082
diff --git a/.gitignore b/.gitignore
index d5baf384c..907bdff07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -180,3 +180,4 @@ AgentHistoryList.json
gcp-login.json
.vscode
.ruff_cache
+.idea
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 94d9e6325..a29739f0b 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -592,6 +592,10 @@ class Agent:
Returns:
List of action results
"""
+ # Execute initial actions if provided
+ if self.initial_actions:
+ await self.controller.multi_act(self.initial_actions, self.browser_context, check_for_new_elements=False)
+
results = []
for i, history_item in enumerate(history.history):