Skip to content

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

Bridge BrowserProfile cloud mode

Magnus Müller544098489752
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.md
index 42f1f4b72..4a2b03994 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/RUST_AGENT_INTEGRATION_FEATURES.md
@@ -90,10 +90,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai
- Multi-step or non-navigation `initial_actions` are now passed to the Rust terminal task as an ordered Browser Use action list instead of being silently stored and dropped.
- Proof: `test_rust_agent_preserves_ordered_initial_actions_context`.
+17. BrowserProfile cloud bridge
+ - `BrowserProfile(use_cloud=True)` and compatible `cloud_browser=True` profiles now select terminal `browser_mode="cloud"`.
+ - CDP URLs still select `remote-cdp`, and explicit browser mode environment variables still override profile preferences.
+ - Proof: `test_rust_agent_translates_browser_profile_cloud`.
+
## 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` (25 tests)
+- `uv run pytest -q tests/ci/test_rust_agent.py` (26 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.py
index 3b33a1a5e..e55be1cbd 100644
--- a/browser_use/rust/service.py
+++ b/browser_use/rust/service.py
@@ -95,6 +95,16 @@ def _extract_headless_preference(browser_session: BrowserSession | None, browser
return None
+def _extract_cloud_preference(browser_session: BrowserSession | None, browser_profile: BrowserProfile | None) -> bool:
+ session_profile = getattr(browser_session, 'browser_profile', None)
+ for profile in (session_profile, browser_profile, browser_session):
+ for attr in ('use_cloud', 'cloud_browser'):
+ value = getattr(profile, attr, None)
+ if isinstance(value, bool) and value:
+ return True
+ return False
+
+
def _navigation_url_from_action(action: Any) -> str | None:
if not isinstance(action, dict):
return None
@@ -850,6 +860,8 @@ class Agent(Generic[AgentStructuredOutput]):
value = os.environ.get('BROWSER_USE_BROWSER_MODE')
if value:
return value
+ if _extract_cloud_preference(self.browser_session, self.browser_profile):
+ return 'cloud'
headless = _extract_headless_preference(self.browser_session, self.browser_profile)
if headless is False:
return 'managed-headed'
diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.py
index 42d2e9706..61353d17a 100644
--- a/tests/ci/test_rust_agent.py
+++ b/tests/ci/test_rust_agent.py
@@ -171,6 +171,23 @@ def test_rust_agent_browser_mode_env_overrides_profile_headless(monkeypatch):
assert agent._run_env()['LLM_BROWSER_BROWSER_MODE'] == 'cloud'
+def test_rust_agent_translates_browser_profile_cloud(monkeypatch):
+ from browser_use.rust import Agent
+
+ class CloudProfile:
+ use_cloud = True
+ headless = False
+
+ monkeypatch.setenv('BROWSER_USE_TERMINAL_BINARY', '/tmp/browser-use-terminal')
+ monkeypatch.delenv('BROWSER_USE_RUST_BROWSER_MODE', raising=False)
+ monkeypatch.delenv('BROWSER_USE_BROWSER_MODE', raising=False)
+
+ agent = Agent(task='report title', browser_profile=CloudProfile())
+
+ assert 'browser_mode="cloud"' in agent._run_argv(max_steps=4)
+ assert agent._run_env()['LLM_BROWSER_BROWSER_MODE'] == 'cloud'
+
+
def test_rust_agent_mirrors_direct_url_startup():
from browser_use.rust import Agent