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
Check for google rate limit error
magmuellerce4cc8df986d
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 0b6448f89..682049f81 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -15,6 +15,7 @@ from pathlib import Pathfrom typing import Any, Callable, Dict, List, Optional, Type, TypeVarfrom dotenv import load_dotenv+from google.api_core.exceptions import ResourceExhaustedfrom langchain_core.language_models.chat_models import BaseChatModelfrom langchain_core.messages import (BaseMessage,@@ -313,7 +314,7 @@ class Agent:error_msg += '\n\nReturn a valid JSON object with the required fields.'self.consecutive_failures += 1- elif isinstance(error, RateLimitError):+ elif isinstance(error, RateLimitError) or isinstance(error, ResourceExhausted):logger.warning(f'{prefix}{error_msg}')await asyncio.sleep(self.retry_delay)self.consecutive_failures += 1@@ -602,7 +603,7 @@ class Agent:# Execute initial actions if providedif self.initial_actions:await self.controller.multi_act(self.initial_actions, self.browser_context, check_for_new_elements=False)-+results = []for i, history_item in enumerate(history.history):