Skip to content

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

dont reset BrowserSession foreground page on Agent.__init__

Nick Sweeting5a70f1f1ceee
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 3aa3866db..574dc586d 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -325,12 +325,12 @@ class Agent(Generic[Context]):
'Call: await browser_session.start()'
)
- # always copy sessions that are passed in to avoid conflicting with other agents sharing the same session
+ # always copy sessions that are passed in to avoid agents overwriting each other's agent_current_page and human_current_page by accident
self.browser_session = browser_session.model_copy(
- update={
- 'agent_current_page': None,
- 'human_current_page': None,
- },
+ # update={
+ # 'agent_current_page': None, # dont reset these, let the next agent start on the same page as the last agent
+ # 'human_current_page': None,
+ # },
)
else:
self.browser_session = BrowserSession(