Skip to content

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

fix browser_session initialization based on old browser= arg

Nick Sweetingf85ca0022cea
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 573f842a5..296767129 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -301,6 +301,9 @@ class Agent(Generic[Context]):
else:
self.memory = None
+ if isinstance(browser, BrowserSession):
+ browser_session = browser_session or browser
+
browser_context = page.context if page else browser_context
# assert not (browser_session and browser_profile), 'Cannot provide both browser_session and browser_profile'
# assert not (browser_session and browser), 'Cannot provide both browser_session and browser'