Skip to content

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

Added DEFAULT_BROWSER_PROFILE as fallback for browser_profile in Agent class initialization

Magnus Müller48e94def72b9
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 55517bdaf..4cf998bb8 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -13,6 +13,8 @@ from typing import Any, Generic, TypeVar
from dotenv import load_dotenv
+from browser_use.browser.session import DEFAULT_BROWSER_PROFILE
+
load_dotenv()
from langchain_core.language_models.chat_models import BaseChatModel
@@ -291,7 +293,7 @@ class Agent(Generic[Context]):
assert not (browser_profile and browser_context), 'Cannot provide both browser_profile and browser_context'
assert not (browser and browser_context), 'Cannot provide both browser and browser_context'
assert not (browser_session and browser_context), 'Cannot provide both browser_session and browser_context'
-
+ browser_profile = browser_profile or DEFAULT_BROWSER_PROFILE
self.browser_session = browser_session or BrowserSession(
profile=browser_profile, browser=browser, browser_context=browser_context
)