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
Merge remote-tracking branch 'origin/main' into refactor-agent-stable
Magnus Müllerfbc056660c05
diff --cc browser_use/agent/service.pyindex a2e5b61be,b3d3b9637..f38bdfbcd--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@@ -958,21 -934,25 +958,25 @@@ class Agent(Generic[Context, AgentStrucreturn text.strip()@time_execution_async('--get_next_action')- async def get_next_action(self, input_messages: list[BaseMessage]) -> AgentOutput:+ async def get_model_output(self, input_messages: list[BaseMessage]) -> AgentOutput:"""Get next action from LLM based on current state"""- response = await self.llm.ainvoke(input_messages, output_format=self.AgentOutput)- parsed = response.completion+ try:+ response = await self.llm.ainvoke(input_messages, output_format=self.AgentOutput)+ parsed = response.completion- # cut the number of actions to max_actions_per_step if needed- if len(parsed.action) > self.settings.max_actions_per_step:- parsed.action = parsed.action[: self.settings.max_actions_per_step]+ # cut the number of actions to max_actions_per_step if needed+ if len(parsed.action) > self.settings.max_actions_per_step:+ parsed.action = parsed.action[: self.settings.max_actions_per_step]- if not (hasattr(self.state, 'paused') and (self.state.paused or self.state.stopped)):- log_response(parsed, self.controller.registry.registry, self.logger)+ if not (hasattr(self.state, 'paused') and (self.state.paused or self.state.stopped)):+ log_response(parsed, self.controller.registry.registry, self.logger)- self._log_next_action_summary(parsed)- return parsed+ self._log_next_action_summary(parsed)+ return parsed+ except ValidationError as e:+ # Just re-raise - Pydantic's validation errors are already descriptive+ raisedef _log_agent_run(self) -> None:"""Log the agent run"""