Skip to content

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

Fix timeout exception handling in Agent class

Magnus Müller724dc15b2900
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 38a4f1863..5d542d365 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -739,7 +739,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
model_output = await asyncio.wait_for(
self._get_model_output_with_retry(input_messages), timeout=self.settings.llm_timeout
)
- except asyncio.TimeoutError:
+ except TimeoutError:
raise TimeoutError(
f'LLM call timed out after {self.settings.llm_timeout} seconds. Generate less tokens and try again.'
)