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
Bridge BrowserProfile executable path
Magnus Müller79808832716d
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 19a3cf749..bd8303859 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -130,10 +130,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai- The terminal core maps that value to `browser connect managed --profile ...`, preserving persistent browser state without passing `--user-data-dir` as a raw Chromium arg.- Proof: `test_rust_agent_translates_browser_profile_user_data_dir` and `bare_browser_connect_resolves_to_selected_managed_mode_with_profile_dir`.+25. BrowserProfile managed executable path bridge+ - `BrowserProfile.executable_path` is serialized into `CHROME_PATH` for terminal managed Chromium runs.+ - The terminal core already tries `CHROME_PATH` first when launching managed Chromium, so custom Browser Use browser binaries are preserved without changing the Rust launcher.+ - Proof: `test_rust_agent_translates_browser_profile_executable_path`.+## Current Verification- `python3 -m py_compile browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`-- `uv run pytest -q tests/ci/test_rust_agent.py` (34 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (35 tests)- `cargo build -q -p browser-use-cli`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent bare_browser_connect_resolves_to_selected_managed_mode_with_launch_args -- --nocapture`diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 17a4b1878..7f99bb571 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -176,6 +176,15 @@ def _managed_browser_profile_dir(browser_session: BrowserSession | None, browserreturn None+def _managed_browser_executable_path(browser_session: BrowserSession | None, browser_profile: BrowserProfile | None) -> str | None:+ session_profile = getattr(browser_session, 'browser_profile', None)+ for profile in (session_profile, browser_profile, browser_session):+ value = getattr(profile, 'executable_path', None)+ if isinstance(value, (str, os.PathLike)) and str(value):+ return str(Path(value).expanduser())+ return None++def _is_managed_browser_mode(mode: str) -> bool:normalized = mode.strip().lower().replace('_', '-').replace(' ', '-')return normalized in {'managed-headless', 'headless', 'headless-chromium', 'managed-headed', 'managed', 'headed'}@@ -704,6 +713,7 @@ class Agent(Generic[AgentStructuredOutput]):self.prohibited_domains = _extract_profile_domains(self.browser_session, self.browser_profile, 'prohibited_domains')self.managed_browser_args = _managed_browser_launch_args(self.browser_session, self.browser_profile)self.managed_browser_profile_dir = _managed_browser_profile_dir(self.browser_session, self.browser_profile)+ self.managed_browser_executable_path = _managed_browser_executable_path(self.browser_session, self.browser_profile)self.sensitive_data_context = _sensitive_data_context(sensitive_data)self.display_files_in_done_text = display_files_in_done_textself.file_system_path = file_system_path@@ -1153,6 +1163,8 @@ class Agent(Generic[AgentStructuredOutput]):env['BU_MANAGED_BROWSER_ARGS'] = json.dumps(self.managed_browser_args)if self.managed_browser_profile_dir and _is_managed_browser_mode(browser_mode):env['BU_MANAGED_BROWSER_PROFILE'] = self.managed_browser_profile_dir+ if self.managed_browser_executable_path and _is_managed_browser_mode(browser_mode):+ env['CHROME_PATH'] = self.managed_browser_executable_pathreturn envdef _session_id_from_stdout(self, stdout: str) -> str | None:diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 9d56d34c9..8bdde5aad 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -289,6 +289,35 @@ def test_rust_agent_translates_browser_profile_user_data_dir(monkeypatch, tmp_paassert env['BU_MANAGED_BROWSER_PROFILE'] == str(profile_dir)+def test_rust_agent_translates_browser_profile_executable_path(monkeypatch, tmp_path):+ from browser_use.rust import Agent++ chrome_path = tmp_path / 'custom chrome'++ class BrowserProfile:+ headless = True+ executable_path = chrome_path++ monkeypatch.setenv('BROWSER_USE_TERMINAL_BINARY', '/tmp/browser-use-terminal')+ monkeypatch.setenv('CHROME_PATH', '/usr/bin/existing-chrome')+ monkeypatch.delenv('BROWSER_USE_RUST_BROWSER_MODE', raising=False)+ monkeypatch.delenv('BROWSER_USE_BROWSER_MODE', raising=False)++ agent = Agent(task='report title', browser_profile=BrowserProfile())+ env = agent._run_env()++ assert env['LLM_BROWSER_BROWSER_MODE'] == 'managed-headless'+ assert agent.managed_browser_executable_path == str(chrome_path)+ assert env['CHROME_PATH'] == str(chrome_path)++ monkeypatch.setenv('BROWSER_USE_BROWSER_MODE', 'cloud')+ cloud_agent = Agent(task='report title', browser_profile=BrowserProfile())+ cloud_env = cloud_agent._run_env()++ assert cloud_env['LLM_BROWSER_BROWSER_MODE'] == 'cloud'+ assert cloud_env['CHROME_PATH'] == '/usr/bin/existing-chrome'++def test_rust_agent_adds_browser_profile_domain_constraints():from browser_use.rust import Agent