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
address cubic comments and clean up new example
Alezander9bf15d159da10
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 8396957a9..432d737fb 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -929,7 +929,11 @@ class Agent(Generic[Context, AgentStructuredOutput]):)# Call LLM with JudgementResult as output format- kwargs: dict = {'output_format': JudgementResult, 'request_type': 'judge'}+ kwargs: dict = {'output_format': JudgementResult}++ # Only pass request_type for ChatBrowserUse (other providers don't support it)+ if self.judge_llm.provider == 'browser-use':+ kwargs['request_type'] = 'judge'try:response = await self.judge_llm.ainvoke(input_messages, **kwargs)diff --git a/browser_use/llm/browser_use/chat.py b/browser_use/llm/browser_use/chat.pyindex 4298dc0f9..9e97ecbb3 100644--- a/browser_use/llm/browser_use/chat.py+++ b/browser_use/llm/browser_use/chat.py@@ -79,10 +79,14 @@ class ChatBrowserUse(BaseChatModel):return self.model@overload- async def ainvoke(self, messages: list[BaseMessage], output_format: None = None) -> ChatInvokeCompletion[str]: ...+ async def ainvoke(+ self, messages: list[BaseMessage], output_format: None = None, request_type: str = 'browser_agent'+ ) -> ChatInvokeCompletion[str]: ...@overload- async def ainvoke(self, messages: list[BaseMessage], output_format: type[T]) -> ChatInvokeCompletion[T]: ...+ async def ainvoke(+ self, messages: list[BaseMessage], output_format: type[T], request_type: str = 'browser_agent'+ ) -> ChatInvokeCompletion[T]: ...@observe(name='chat_browser_use_ainvoke')async def ainvoke(diff --git a/examples/features/judge_trace.py b/examples/features/judge_trace.pyindex e23c1b07d..d89673668 100644--- a/examples/features/judge_trace.py+++ b/examples/features/judge_trace.py@@ -19,9 +19,7 @@ from browser_use import Agent, ChatBrowserUseasync def main():- llm = ChatBrowserUse(base_url='http://localhost:8080')- # Use gemini flash for judging since it supports vision + structured output- # judge_llm = ChatGoogle(model='gemini-flash-latest')+ llm = ChatBrowserUse()task = "Search Google for 'what is browser automation' and tell me the top 3 results"agent = Agent(task=task, llm=llm, use_judge=True, judge_llm=llm)history = await agent.run()