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 Rust agent browser profile CDP
Magnus Müller3d3de8bfd31f
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 98dae8716..f907430b8 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -24,7 +24,8 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai4. Browser mode bridge- The wrapper sets `LLM_BROWSER_BROWSER_MODE` so terminal browser selection follows Browser Use wrapper settings.- `BrowserSession(cdp_url=...)` selects `remote-cdp` and forwards `BU_CDP_URL`.- - Proof: `test_rust_agent_translates_browser_use_args_to_terminal`.+ - `BrowserProfile(cdp_url=...)` also selects `remote-cdp` and forwards `BU_CDP_URL`.+ - Proof: `test_rust_agent_translates_browser_use_args_to_terminal` and `test_rust_agent_translates_browser_profile_cdp_url`.5. Remote CDP terminal mode- Terminal browser handling now accepts locked `remote-cdp` mode instead of rejecting `browser connect remote-cdp`.@@ -50,7 +51,7 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai## 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` (12 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (13 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`- Managed-headless end-to-end:diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 412c71750..2a3c04b08 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -72,6 +72,15 @@ def _extract_cdp_url(browser_session: BrowserSession | None) -> str | None:return None+def _extract_profile_cdp_url(browser_profile: BrowserProfile | None) -> str | None:+ if browser_profile is None:+ return None+ value = getattr(browser_profile, 'cdp_url', None)+ if isinstance(value, str) and value:+ return value+ return None++def _initial_navigation_url(initial_actions: Any) -> str | None:if not isinstance(initial_actions, list):return None@@ -514,19 +523,17 @@ class Agent(Generic[AgentStructuredOutput]):return ['--state-dir', state_dir] if state_dir else []def _browser_mode(self) -> str:- if _extract_cdp_url(self.browser_session):+ if _extract_cdp_url(self.browser_session) or _extract_profile_cdp_url(self.browser_profile):return 'remote-cdp'value = os.environ.get('BROWSER_USE_RUST_BROWSER_MODE')if value:return value- if self.browser_profile and getattr(self.browser_profile, 'cdp_url', None):- return 'managed-headless'return os.environ.get('BROWSER_USE_BROWSER_MODE', 'managed-headless')def _run_env(self) -> dict[str, str]:env = os.environ.copy()env['LLM_BROWSER_BROWSER_MODE'] = self._browser_mode()- cdp_url = _extract_cdp_url(self.browser_session)+ cdp_url = _extract_cdp_url(self.browser_session) or _extract_profile_cdp_url(self.browser_profile)if cdp_url:env['BU_CDP_URL'] = cdp_urlreturn envdiff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex e0f4068a8..573ba8de0 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -111,6 +111,21 @@ def test_rust_agent_translates_browser_use_args_to_terminal(monkeypatch):assert env['LLM_BROWSER_BROWSER_MODE'] == 'remote-cdp'+def test_rust_agent_translates_browser_profile_cdp_url(monkeypatch):+ from browser_use.rust import Agent++ class BrowserProfile:+ cdp_url = 'http://127.0.0.1:9222'++ monkeypatch.setenv('BROWSER_USE_TERMINAL_BINARY', '/tmp/browser-use-terminal')+ agent = Agent(task='report title', browser_profile=BrowserProfile())+ env = agent._run_env()++ assert 'browser_mode="remote-cdp"' in agent._run_argv(max_steps=4)+ assert env['BU_CDP_URL'] == 'http://127.0.0.1:9222'+ assert env['LLM_BROWSER_BROWSER_MODE'] == 'remote-cdp'++def test_rust_agent_default_codex_model_matches_chatgpt_account(monkeypatch):from browser_use.rust import Agent