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
Enable Rust agent flash mode for Browser Use LLM
Magnus Müllerb49d2fcd99c4
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 049880e06..acadc0370 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -536,10 +536,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at terminal main `ee- Explicit `task_id` still controls `agent.id` and `agent.task_id`, while injected `AgentState` objects remain preserved for restored runs.- Proof: `test_rust_agent_state_id_defaults_like_browser_use`.+106. Rust Agent Browser Use LLM flash-mode parity+ - The Rust-backed Agent now mirrors Browser Use's constructor behavior that enables `settings.flash_mode` when the supplied LLM has `provider == 'browser-use'`.+ - Non-Browser Use providers retain the caller's flash-mode setting, and Browser Use-provider models build the same flash-mode action output class family.+ - Proof: `test_rust_agent_enables_flash_mode_for_browser_use_llm_provider`.+## Current Verification- `python3 -m py_compile browser_use/agent/service.py 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` (79 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (80 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 2a99ddd69..8ceaa1bf7 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -1099,6 +1099,8 @@ class Agent(Generic[AgentStructuredOutput]):raise ValueError('Cannot specify both "browser" and "browser_session".')if tools is not None and controller is not None:raise ValueError('Cannot specify both "tools" and "controller".')+ if getattr(llm, 'provider', None) == 'browser-use':+ flash_mode = Trueif page_extraction_llm is None:page_extraction_llm = llmself.id = task_id or uuid7str()diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 5f20b5610..7a8eaebe9 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -913,6 +913,35 @@ def test_rust_agent_defaults_page_extraction_llm_to_main_llm():assert str(id(extraction_llm)) in override_agent.token_cost_service.registered_llms+def test_rust_agent_enables_flash_mode_for_browser_use_llm_provider():+ from browser_use.agent.service import _PythonAgent as BrowserUseAgent+ from browser_use.rust import Agent as RustAgent++ class BrowserUseLLM:+ model = 'browser-use-test'+ provider = 'browser-use'++ async def ainvoke(self, messages, output_format=None, **kwargs):+ return type('Result', (), {'usage': None})()++ class OtherLLM:+ model = 'gpt-test'+ provider = 'test'++ async def ainvoke(self, messages, output_format=None, **kwargs):+ return type('Result', (), {'usage': None})()++ browser_use_llm = BrowserUseLLM()+ browser_use_agent = BrowserUseAgent(task='Use Browser Use model.', llm=browser_use_llm, directly_open_url=False)+ rust_browser_use_agent = RustAgent(task='Use Browser Use model.', llm=browser_use_llm, directly_open_url=False)+ rust_other_agent = RustAgent(task='Use another model.', llm=OtherLLM(), directly_open_url=False)++ assert browser_use_agent.settings.flash_mode is True+ assert rust_browser_use_agent.settings.flash_mode is True+ assert rust_other_agent.settings.flash_mode is False+ assert rust_browser_use_agent.AgentOutput.__name__ == browser_use_agent.AgentOutput.__name__++def test_rust_agent_state_id_defaults_like_browser_use():from browser_use.agent.service import _PythonAgent as BrowserUseAgentfrom browser_use.agent.views import AgentState