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
feat: updated the thinking budget
Saurav Panda041d03a93f94
diff --git a/browser_use/llm/google/chat.py b/browser_use/llm/google/chat.pyindex 7c8260197..44d65170d 100644--- a/browser_use/llm/google/chat.py+++ b/browser_use/llm/google/chat.py@@ -88,7 +88,8 @@ class ChatGoogle(BaseChatModel):temperature: float | None = 0.5top_p: float | None = Noneseed: int | None = None- thinking_budget: int | None = None # for gemini-2.5 flash, flash-lite, and gemini-3 models, default will be set to 0+ thinking_budget: int | None = None # for Gemini 2.5: 0 disables (flash), -1 for dynamic, or token count+ thinking_level: Literal['low', 'high'] | None = None # for Gemini 3: 'low' minimizes latency, 'high' maximizes depthmax_output_tokens: int | None = 8096config: types.GenerateContentConfigDict | None = Noneinclude_system_in_user: bool = False@@ -230,15 +231,36 @@ class ChatGoogle(BaseChatModel):if self.seed is not None:config['seed'] = self.seed- # set default for flash, flash-lite, gemini-flash-lite-latest, gemini-flash-latest, and gemini-3 models- if self.thinking_budget is None and (- 'gemini-2.5-flash' in self.model or 'gemini-flash' in self.model or 'gemini-3' in self.model- ):- self.thinking_budget = 0+ # Configure thinking based on model version+ # Gemini 3 uses thinking_level; Gemini 2.5 uses thinking_budget+ is_gemini_3 = 'gemini-3' in self.model- if self.thinking_budget is not None:- thinking_config_dict: types.ThinkingConfigDict = {'thinking_budget': self.thinking_budget}+ if is_gemini_3:+ # Validate: thinking_budget should not be set for Gemini 3+ if self.thinking_budget is not None:+ self.logger.warning(+ f'thinking_budget={self.thinking_budget} is deprecated for Gemini 3 models and may cause '+ f'suboptimal performance. Use thinking_level instead ("low" or "high").'+ )+ # Gemini 3: use thinking_level (not thinking_budget)+ if self.thinking_level is None:+ self.thinking_level = 'low' # default to 'low' for latency/cost optimization+ level = types.ThinkingLevel.LOW if self.thinking_level == 'low' else types.ThinkingLevel.HIGH+ thinking_config_dict: types.ThinkingConfigDict = {'thinking_level': level}config['thinking_config'] = thinking_config_dict+ else:+ # Validate: thinking_level should not be set for Gemini 2.5+ if self.thinking_level is not None:+ self.logger.warning(+ f'thinking_level="{self.thinking_level}" is not supported for Gemini 2.5 models. '+ f'Use thinking_budget instead (0 to disable, -1 for dynamic, or token count).'+ )+ # Gemini 2.5 and earlier: use thinking_budget+ if self.thinking_budget is None and ('gemini-2.5-flash' in self.model or 'gemini-flash' in self.model):+ self.thinking_budget = 0+ if self.thinking_budget is not None:+ thinking_config_dict: types.ThinkingConfigDict = {'thinking_budget': self.thinking_budget}+ config['thinking_config'] = thinking_config_dictif self.max_output_tokens is not None:config['max_output_tokens'] = self.max_output_tokensdiff --git a/examples/simple.py b/examples/simple.pyindex 449237819..321f6471a 100644--- a/examples/simple.py+++ b/examples/simple.py@@ -6,12 +6,12 @@ Setup:from dotenv import load_dotenv-from browser_use import Agent, ChatBrowserUse+from browser_use import Agent, ChatGoogleload_dotenv()agent = Agent(- task='Find the number of stars of the following repos: browser-use, playwright, stagehand, react, nextjs',- llm=ChatBrowserUse(model='bu-2-0'),+ task='Who are founders of Browser Use',+ llm=ChatGoogle(model='gemini-3-pro-preview'),)agent.run_sync()