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
Refactor action result handling in message_manager and controller services
Magnus Müllere8f2467ab247
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.pyindex 27f43d7bb..71c9a0879 100644--- a/browser_use/agent/message_manager/service.py+++ b/browser_use/agent/message_manager/service.py@@ -391,7 +391,7 @@ My next action is to click on the iPhone link at index [4] to navigate to Apple'for idx, action_result in enumerate(result):if action_result.update_read_state:self.read_state_description += action_result.extracted_content + '\n'- if action_result.memory:+ elif action_result.memory:action_results += f'Action {idx + 1} Result: {action_result.memory}\n'elif action_result.error:action_results += f'Action {idx + 1} Error: {action_result.error[:200]}\n'@@ -401,7 +401,7 @@ My next action is to click on the iPhone link at index [4] to navigate to Apple''⚠️ ActionResult does not have memory but has extracted_content. This is not recommended as extracted_content can be too long.')else:- raise ValueError(f'Action {idx + 1} has no memory or error:\n{action_result}')+ logger.debug(f'Action {idx + 1} has no memory or error:\n{action_result}')self.agent_history_description += f"""## Step {step_number}Evaluation: {model_output.current_state.evaluation_previous_goal}diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex 1dc597671..c83779133 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -294,14 +294,13 @@ class Controller(Generic[Context]):return ActionResult(extracted_content=msg,include_in_memory=False,- memory=f"Extracted '{content_to_extract}'",update_read_state=True,)except Exception as e:logger.debug(f'Error extracting content: {e}')msg = f'📄 Extracted from page\n: {content}\n'logger.info(msg)- return ActionResult(extracted_content=msg)+ return ActionResult(error=str(e))@self.registry.action('Get the accessibility tree of the page in the format "role name" with the number_of_elements to return',