Skip to content

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

fix config merging between browser and context

Nick Sweeting2ea79ecd9218
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.py
index 1a27486ea..b393638a1 100644
--- a/browser_use/browser/browser.py
+++ b/browser_use/browser/browser.py
@@ -133,9 +133,10 @@ class Browser:
async def new_context(self, config: BrowserContextConfig | None = None) -> BrowserContext:
"""Create a browser context"""
- return BrowserContext(
- config=config or BrowserContextConfig(**(self.config.model_dump() if self.config else {})), browser=self
- )
+ browser_config = dict(self.config or {})
+ context_config = dict(config or {})
+ merged_config = {**browser_config, **context_config}
+ return BrowserContext(config=BrowserContextConfig(**merged_config), browser=self)
async def get_playwright_browser(self) -> PlaywrightBrowser:
"""Get a browser context"""