Skip to content

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

minor compat msg improvements and dead code removal

Nick Sweetingb512e08364f4
diff --git a/browser_use/agent/message_manager/__init__.py b/browser_use/agent/message_manager/__init__.py
deleted file mode 100644
index 072c3dd81..000000000
--- a/browser_use/agent/message_manager/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-"""
-Message Manager for Browser Use Agent.
-"""
-# Fix circular import by only importing names in functions where needed
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 964871f30..d71f8f211 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -13,8 +13,6 @@ from typing import Any, Generic, TypeVar
from dotenv import load_dotenv
-from browser_use.browser.types import BrowserProfile
-
load_dotenv()
from langchain_core.language_models.chat_models import BaseChatModel
@@ -26,7 +24,6 @@ from langchain_core.messages import (
from playwright.async_api import Browser, BrowserContext
from pydantic import BaseModel, ValidationError
-# from lmnr.sdk.decorators import observe
from browser_use.agent.gif import create_history_gif
from browser_use.agent.memory import Memory, MemoryConfig
from browser_use.agent.message_manager.service import MessageManager, MessageManagerSettings
@@ -51,7 +48,9 @@ from browser_use.agent.views import (
StepMetadata,
ToolCallingMethod,
)
-from browser_use.browser import BrowserSession
+from browser_use.browser import BrowserProfile, BrowserSession
+
+# from lmnr.sdk.decorators import observe
from browser_use.browser.views import BrowserState
from browser_use.controller.registry.views import ActionModel
from browser_use.controller.service import Controller
@@ -60,7 +59,7 @@ from browser_use.dom.history_tree_processor.service import (
HistoryTreeProcessor,
)
from browser_use.exceptions import LLMException
-from browser_use.telemetry import ProductTelemetry
+from browser_use.telemetry.service import ProductTelemetry
from browser_use.telemetry.views import (
AgentTelemetryEvent,
)
diff --git a/browser_use/browser/compat.py b/browser_use/browser/compat.py
index 391927306..5a88141e7 100644
--- a/browser_use/browser/compat.py
+++ b/browser_use/browser/compat.py
@@ -1,28 +1,32 @@
DEPRECATION_MESSAGE = """
-⚠️ {} is deprecated. Use the ✨ new, simplified BrowserSession(**all_config_here) ✨ instead!\n
- from browser_use.browser import BrowserSession, BrowserProfile
+⚠️ {} is deprecated. Use the ✨ new, simplified BrowserProfile and BrowserSession ✨ instead!\n
+ from browser_use.browser import BrowserProfile, BrowserSession
browser_profile = BrowserProfile(
- # ⬇️ the old BrowserConfig, BrowserContextConfig kwargs all go in one place now:
+ # ⬇️ the old BrowserConfig, BrowserContextConfig, and playwright launch/context kwargs all go in one place now:
headless=False,
disable_security=False,
keep_alive=True,
- extra_browser_args=['--start-maximized'],
+ args=['--start-maximized'],
+ ignore_default_args=['--enable-automation'],
allowed_domains=['example.com', '*.google.com'],
- browser_binary_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ user_data_dir='/path/to/user_data_dir',
+ downloads_path='/path/to/downloads',
...
+ # ⬆️ see the full list of options here: https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch-persistent-context
)
# then start a session using the profile to connect/launch to the live browser:
browser_session = BrowserSession(
- profile=browser_profile,
+ browser_profile=browser_profile,
# pass a CDP URL to connect to an existing browser instance:
cdp_url='http://localhost:9222',
# or provide a custom binary to launch:
- browser_binary_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
- # or pass live playwright or patchright objects to use them directly:
- browser=playwright_browser,
- browser_context=playwright_browser_context,
+ executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ # or pass live playwright or patchright objects to use an existing browser connection directly:
+ browser=playwright_browser_obj,
+ browser_context=playwright_browser_context_obj,
)
agent = Agent(browser_session=browser_session, ...)
...