Skip to content

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

Refactor model timeout logic and enhance ModelProviderError initialization

Magnus Müller5d749793ecda
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index d96b67d7e..68d677b6d 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -213,7 +213,9 @@ class Agent(Generic[Context, AgentStructuredOutput]):
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:
+ if 'gemini' in model_name:
+ return 45
+ elif '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
diff --git a/browser_use/llm/exceptions.py b/browser_use/llm/exceptions.py
index aac18d7c5..809edcc18 100644
--- a/browser_use/llm/exceptions.py
+++ b/browser_use/llm/exceptions.py
@@ -11,7 +11,9 @@ class ModelProviderError(ModelError):
status_code: int = 502,
model: str | None = None,
):
- super().__init__(message, status_code)
+ super().__init__(message)
+ self.message = message
+ self.status_code = status_code
self.model = model
diff --git a/browser_use/llm/google/chat.py b/browser_use/llm/google/chat.py
index 24f823354..1035777e6 100644
--- a/browser_use/llm/google/chat.py
+++ b/browser_use/llm/google/chat.py
@@ -76,7 +76,7 @@ class ChatGoogle(BaseChatModel):
top_p: float | None = None
seed: int | None = None
thinking_budget: int | None = None # for flash and flash-lite models, default will be set to 0
- max_output_tokens: int | None = 4096
+ max_output_tokens: int | None = 8192
config: types.GenerateContentConfigDict | None = None
include_system_in_user: bool = False
supports_structured_output: bool = True # New flag