Skip to content

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

Bridge BrowserProfile chromium sandbox

Magnus Müllerc195a6956de6
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.md
index 1f6d855e0..4db460fb1 100644
--- a/RUST_AGENT_INTEGRATION_FEATURES.md
+++ b/RUST_AGENT_INTEGRATION_FEATURES.md
@@ -140,10 +140,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai
- Values are stringified for process-env compatibility, unsupported nested values are ignored, and cloud/CDP runs do not receive managed browser launch env overrides.
- Proof: `test_rust_agent_translates_browser_profile_env`.
+27. BrowserProfile chromium sandbox bridge
+ - `BrowserProfile(chromium_sandbox=False)` now emits the same standard Chromium sandbox-disable flags Browser Use applies for local managed launches.
+ - The flags are passed through `BU_MANAGED_BROWSER_ARGS` and deduped with caller-provided `BrowserProfile.args`.
+ - Proof: `test_rust_agent_translates_browser_profile_chromium_sandbox`.
+
## 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` (36 tests)
+- `uv run pytest -q tests/ci/test_rust_agent.py` (37 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.py
index 3783e726c..9b9083b41 100644
--- a/browser_use/rust/service.py
+++ b/browser_use/rust/service.py
@@ -18,7 +18,7 @@ from uuid_extensions import uuid7str
from browser_use.agent.views import ActionResult, AgentHistory, AgentHistoryList, AgentSettings, AgentState, StepMetadata
from browser_use.browser import BrowserProfile, BrowserSession
-from browser_use.browser.profile import CHROME_DETERMINISTIC_RENDERING_ARGS, CHROME_DISABLE_SECURITY_ARGS
+from browser_use.browser.profile import CHROME_DETERMINISTIC_RENDERING_ARGS, CHROME_DISABLE_SECURITY_ARGS, CHROME_DOCKER_ARGS
from browser_use.browser.views import BrowserStateHistory, TabInfo
from browser_use.tokens.views import ModelUsageStats, UsageSummary
@@ -153,6 +153,9 @@ def _managed_browser_launch_args(browser_session: BrowserSession | None, browser
if getattr(profile, 'deterministic_rendering', False) is True:
for arg in CHROME_DETERMINISTIC_RENDERING_ARGS:
_append_unique(args, seen, arg)
+ if getattr(profile, 'chromium_sandbox', None) is False:
+ for arg in CHROME_DOCKER_ARGS:
+ _append_unique(args, seen, arg)
_append_unique(args, seen, _window_size_arg(getattr(profile, 'window_size', None)))
proxy = getattr(profile, 'proxy', None)
proxy_server = _value_from_object(proxy, 'server')
diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.py
index 7efd2985e..a8d8fbf74 100644
--- a/tests/ci/test_rust_agent.py
+++ b/tests/ci/test_rust_agent.py
@@ -267,6 +267,27 @@ def test_rust_agent_translates_browser_profile_managed_launch_args(monkeypatch):
assert '--user-agent=BrowserUseTest/1.0' in launch_args
+def test_rust_agent_translates_browser_profile_chromium_sandbox(monkeypatch):
+ from browser_use.rust import Agent
+
+ class BrowserProfile:
+ headless = True
+ chromium_sandbox = False
+ args = ['--no-sandbox']
+
+ 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=BrowserProfile())
+ launch_args = json.loads(agent._run_env()['BU_MANAGED_BROWSER_ARGS'])
+
+ assert launch_args.count('--no-sandbox') == 1
+ assert '--disable-gpu-sandbox' in launch_args
+ assert '--disable-setuid-sandbox' in launch_args
+ assert '--disable-dev-shm-usage' in launch_args
+
+
def test_rust_agent_translates_browser_profile_user_data_dir(monkeypatch, tmp_path):
from browser_use.rust import Agent