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
Match Rust agent LLM timeout defaults
Magnus Müller1b7eb0d8fe3c
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex acadc0370..037149cbe 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -541,10 +541,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at terminal main `ee- 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`.+107. Rust Agent LLM timeout default parity+ - The Rust-backed Agent now mirrors Browser Use's constructor timeout defaults by model family: Gemini uses 45 seconds, Groq uses 30 seconds, O3/Claude/Sonnet/DeepSeek use 90 seconds, and other models use 60 seconds.+ - Explicit `llm_timeout` overrides still take precedence over the model-family heuristic.+ - Proof: `test_rust_agent_llm_timeout_defaults_match_browser_use_model_families`.+## 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` (80 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (81 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 8ceaa1bf7..03f882a0a 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -86,6 +86,17 @@ def _model_name(llm: Any | None) -> str:return os.environ.get('BROWSER_USE_RUST_MODEL', 'gpt-5.3-codex-spark')+def _llm_timeout_for_model(llm: Any | None) -> int:+ model_name = str(getattr(llm, 'model', '') or '').lower()+ if 'gemini' in model_name:+ return 45+ if 'groq' in model_name:+ return 30+ if 'o3' in model_name or 'claude' in model_name or 'sonnet' in model_name or 'deepseek' in model_name:+ return 90+ return 60++def _extract_cdp_url(browser_session: BrowserSession | None) -> str | None:if browser_session is None:return None@@ -1103,6 +1114,8 @@ class Agent(Generic[AgentStructuredOutput]):flash_mode = Trueif page_extraction_llm is None:page_extraction_llm = llm+ if llm_timeout is None:+ llm_timeout = _llm_timeout_for_model(llm)self.id = task_id or uuid7str()self.task_id = self.idself.llm = llm@@ -1150,7 +1163,7 @@ class Agent(Generic[AgentStructuredOutput]):page_extraction_llm=page_extraction_llm,calculate_cost=calculate_cost,include_tool_call_examples=include_tool_call_examples,- llm_timeout=llm_timeout or 60,+ llm_timeout=llm_timeout,step_timeout=step_timeout,final_response_after_failure=final_response_after_failure,)diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 7a8eaebe9..3146cb070 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -942,6 +942,30 @@ def test_rust_agent_enables_flash_mode_for_browser_use_llm_provider():assert rust_browser_use_agent.AgentOutput.__name__ == browser_use_agent.AgentOutput.__name__+def test_rust_agent_llm_timeout_defaults_match_browser_use_model_families():+ from browser_use.agent.service import _PythonAgent as BrowserUseAgent+ from browser_use.rust import Agent as RustAgent++ class LLM:+ provider = 'test'++ def __init__(self, model):+ self.model = model++ async def ainvoke(self, messages, output_format=None, **kwargs):+ return type('Result', (), {'usage': None})()++ for model in ['gpt-test', 'gemini-2.5-pro', 'groq-llama', 'o3-mini', 'claude-sonnet', 'deepseek-chat']:+ browser_use_agent = BrowserUseAgent(task='Inspect timeout.', llm=LLM(model), directly_open_url=False)+ rust_agent = RustAgent(task='Inspect timeout.', llm=LLM(model), directly_open_url=False)++ assert rust_agent.settings.llm_timeout == browser_use_agent.settings.llm_timeout++ override_agent = RustAgent(task='Override timeout.', llm=LLM('gemini-2.5-pro'), llm_timeout=12)++ assert override_agent.settings.llm_timeout == 12++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