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
Default Rust agent page extraction LLM to main LLM
Magnus Müller4dd46806883e
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex b63de39d8..9d5f197b9 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -526,10 +526,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at terminal main `ee- The original Python Agent class remains available privately as `_PythonAgent` for parity audits while common direct service imports run through the Rust core.- Proof: `test_agent_service_export_uses_rust_wrapper`.+104. Rust Agent page-extraction LLM default parity+ - The Rust-backed Agent now mirrors Browser Use's constructor default that uses the main `llm` as `settings.page_extraction_llm` when no dedicated extraction model is provided.+ - Explicit `page_extraction_llm` overrides are still preserved, and both defaulted and explicit extraction models can be registered with token usage tracking.+ - Proof: `test_rust_agent_defaults_page_extraction_llm_to_main_llm`.+## 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` (77 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (78 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 0bfd7ef7a..a472bdf87 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 page_extraction_llm is None:+ page_extraction_llm = llmself.id = task_id or uuid7str()self.task_id = self.idself.llm = llmdiff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 4b18375c5..4be0e60bf 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -880,6 +880,39 @@ def test_rust_agent_exposes_browser_use_settings():assert agent.include_recent_events is True+def test_rust_agent_defaults_page_extraction_llm_to_main_llm():+ from browser_use.rust import Agent++ class LLM:+ model = 'gpt-test'+ provider = 'test'++ async def ainvoke(self, messages, output_format=None, **kwargs):+ return type('Result', (), {'usage': None})()++ class ExtractionLLM:+ model = 'extract-test'+ provider = 'test'++ async def ainvoke(self, messages, output_format=None, **kwargs):+ return type('Result', (), {'usage': None})()++ llm = LLM()+ extraction_llm = ExtractionLLM()++ default_agent = Agent(task='Extract with the main model.', llm=llm)+ override_agent = Agent(+ task='Extract with a dedicated model.',+ llm=llm,+ page_extraction_llm=extraction_llm,+ )++ assert default_agent.settings.page_extraction_llm is llm+ assert override_agent.settings.page_extraction_llm is extraction_llm+ assert str(id(llm)) in default_agent.token_cost_service.registered_llms+ assert str(id(extraction_llm)) in override_agent.token_cost_service.registered_llms++def test_rust_agent_initializes_tools_and_action_models():from browser_use.rust import Agentfrom browser_use.tools.service import Tools