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
Dynamic model timeout
Magnus Müllere454309f5135
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex a28a230c3..d96b67d7e 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -176,7 +176,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):display_files_in_done_text: bool = True,include_tool_call_examples: bool = False,vision_detail_level: Literal['auto', 'low', 'high'] = 'auto',- llm_timeout: int = 90,+ llm_timeout: int | None = None,step_timeout: int = 120,directly_open_url: bool = True,include_recent_events: bool = False,@@ -207,6 +207,21 @@ class Agent(Generic[Context, AgentStructuredOutput]):if available_file_paths is None:available_file_paths = []+ # Set timeout based on model name if not explicitly provided+ if llm_timeout is None:++ def _get_model_timeout(llm_model: BaseChatModel) -> int:+ """Determine timeout based on model name"""+ model_name = getattr(llm_model, 'model', '').lower()+ if 'gemini' in model_name or 'groq' in model_name:+ return 30+ elif 'o3' in model_name or 'claude' in model_name or 'sonnet' in model_name or 'deepseek' in model_name:+ return 90+ else:+ return 60 # Default timeout++ llm_timeout = _get_model_timeout(llm)+self.id = task_id or uuid7str()self.task_id: str = self.idself.session_id: str = uuid7str()diff --git a/browser_use/agent/views.py b/browser_use/agent/views.pyindex 866ead1a4..daa6ee78d 100644--- a/browser_use/agent/views.py+++ b/browser_use/agent/views.py@@ -50,7 +50,7 @@ class AgentSettings(BaseModel):page_extraction_llm: BaseChatModel | None = Nonecalculate_cost: bool = Falseinclude_tool_call_examples: bool = False- llm_timeout: int = 60 # Timeout in seconds for LLM calls+ llm_timeout: int = 60 # Timeout in seconds for LLM calls (auto-detected: 30s for gemini, 90s for o3, 60s default)step_timeout: int = 180 # Timeout in seconds for each stepfinal_response_after_failure: bool = True # If True, attempt one final recovery call after max_failures