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
Multiaction works
magmueller5128b6f0c44c
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.pyindex 542a425a5..d1ed36ceb 100644--- a/browser_use/agent/message_manager/service.py+++ b/browser_use/agent/message_manager/service.py@@ -54,17 +54,21 @@ class MessageManager:task_message = HumanMessage(content=f'Your task is: {task}')self._add_message_with_tokens(task_message)- def add_state_message(self, state: BrowserState, result: Optional[ActionResult] = None) -> None:+ def add_state_message(+ self, state: BrowserState, result: Optional[List[ActionResult]] = None+ ) -> None:"""Add browser state as human message"""# if keep in memory, add to directly to history and add state without result- if result and result.include_in_memory:- if result.extracted_content:- msg = HumanMessage(content=str(result.extracted_content))- self._add_message_with_tokens(msg)- if result.error:- msg = HumanMessage(content=str(result.error)[-self.max_error_length :])- self._add_message_with_tokens(msg)+ if result:+ for r in result:+ if r.include_in_memory:+ if r.extracted_content:+ msg = HumanMessage(content=str(r.extracted_content))+ self._add_message_with_tokens(msg)+ if r.error:+ msg = HumanMessage(content=str(r.error)[-self.max_error_length :])+ self._add_message_with_tokens(msg)result = None# otherwise add state message and result to next message (which will not stay in memory)diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 3a8952de7..c00a441cd 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -133,7 +133,7 @@ class Agent:self.message_manager.add_model_output(model_output)result: list[ActionResult] = await self.controller.multi_act(model_output.action)- self._last_result = result[-1]+ self._last_result = resultfor r in result:if r.is_done:@@ -145,7 +145,7 @@ class Agent:except Exception as e:result = self._handle_step_error(e)- self._last_result = result[-1]+ self._last_result = resultfinally:for r in result:@@ -238,8 +238,10 @@ class Agent:logger.info(f'{emoji} Evaluation: {response.current_state.evaluation_previous_goal}')logger.info(f'🧠 Memory: {response.current_state.memory}')logger.info(f'🎯 Next Goal: {response.current_state.next_goal}')- for action in response.action:- logger.info(f'🛠️ Action: {action.model_dump_json(exclude_unset=True)}')+ for i, action in enumerate(response.action):+ logger.info(+ f'🛠️ Action {i}/{len(response.action)}: {action.model_dump_json(exclude_unset=True)}'+ )def _save_conversation(self, input_messages: list[BaseMessage], response: Any) -> None:"""Save conversation history to file if path is specified"""@@ -361,7 +363,7 @@ class Agent:if not is_valid:logger.info(f'❌ Validator decision: {parsed.reason}')msg = f'The ouput is not yet correct. {parsed.reason}.'- self._last_result = ActionResult(extracted_content=msg, include_in_memory=True)+ self._last_result = [ActionResult(extracted_content=msg, include_in_memory=True)]else:logger.info(f'✅ Validator decision: {parsed.reason}')return is_valid