Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix type errors and add timeout on remove_highlights
Nick Sweeting6ad5c223f006
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex fa4cfceab..329393c24 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -1675,6 +1675,7 @@ class BrowserSession(BaseModel):@require_initialization@time_execution_async('--remove_highlights')+ @retry(timeout=5, retries=0)async def remove_highlights(self):"""Removes all highlight overlays and labels created by the highlightElement function.diff --git a/browser_use/mcp_server.py b/browser_use/mcp_server.pyindex c80e6f1bb..545e7ff3d 100644--- a/browser_use/mcp_server.py+++ b/browser_use/mcp_server.py@@ -358,7 +358,12 @@ class BrowserUseServer:logger.info('Browser session initialized')async def _run_agent_task(- self, task: str, max_steps: int = 100, model: str = 'gpt-4o', allowed_domains: list[str] = None, use_vision: bool = True+ self,+ task: str,+ max_steps: int = 100,+ model: str = 'gpt-4o',+ allowed_domains: list[str] | None = None,+ use_vision: bool = True,) -> str:"""Run an autonomous agent task."""logger.info(f'Running agent task: {task}')@@ -405,7 +410,10 @@ class BrowserUseServer:# Include URLs visitedurls = history.urls()if urls:- results.append(f'\nURLs visited: {", ".join(urls)}')+ # Filter out None values and convert to strings+ valid_urls = [str(url) for url in urls if url is not None]+ if valid_urls:+ results.append(f'\nURLs visited: {", ".join(valid_urls)}')return '\n'.join(results)@@ -418,6 +426,9 @@ class BrowserUseServer:async def _navigate(self, url: str, new_tab: bool = False) -> str:"""Navigate to a URL."""+ if not self.browser_session:+ return 'Error: No browser session active'+if new_tab:page = await self.browser_session.create_new_tab(url)tab_idx = self.browser_session.tabs.index(page)