Skip to content

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

dont force browser session to be started before passing in

Nick Sweeting20d1acfd1c75
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 75e540dd9..198c9d723 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -324,18 +324,6 @@ class Agent(Generic[Context]):
browser_profile = browser_profile or DEFAULT_BROWSER_PROFILE
if browser_session:
- # Check if user is trying to reuse an uninitialized session
- if browser_session.browser_profile.keep_alive and not browser_session.initialized:
- self.logger.error(
- '❌ Passed a BrowserSession with keep_alive=True that is not initialized. '
- 'Call await browser_session.start() before passing it to Agent() to reuse the same browser. '
- 'Otherwise, each agent will launch its own browser instance.'
- )
- raise ValueError(
- 'BrowserSession with keep_alive=True must be initialized before passing to Agent. '
- 'Call: await browser_session.start()'
- )
-
# Always copy sessions that are passed in to avoid agents overwriting each other's agent_current_page and human_current_page by accident
# The model_copy() method now handles copying all necessary fields and setting up ownership
if browser_session._owns_browser_resources: