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
Improve history
mertunsall8c4dc394eea7
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.pyindex 17020e72f..9d97041cb 100644--- a/browser_use/agent/message_manager/service.py+++ b/browser_use/agent/message_manager/service.py@@ -212,7 +212,7 @@ class MessageManager:self.state = stateself.system_prompt = system_messageself.file_system = file_system- self.agent_history_description = 'Agent initialized.\n'+ self.agent_history_description = '<system>Agent initialized</system>\n'self.read_state_description = ''self.sensitive_data_description = ''# Only initialize messages if state is empty@@ -351,7 +351,7 @@ My next action is to click on the iPhone link at index [4] to navigate to Apple'def add_new_task(self, new_task: str) -> None:self.task = new_task- self.agent_history_description += f'\nUser updated USER REQUEST to: {new_task}\n'+ self.agent_history_description += f'\n<system>User updated USER REQUEST to: {new_task}</system>\n'def _update_agent_history_description(self,@@ -365,8 +365,7 @@ My next action is to click on the iPhone link at index [4] to navigate to Apple'result = []step_number = step_info.step_number if step_info else 'unknown'- self.read_state_initialization = 'This is displayed only **one time**, save this information if you need it later.\n'- self.read_state_description = self.read_state_initialization+ self.read_state_description = ''action_results = ''result_len = len(result)@@ -376,36 +375,36 @@ My next action is to click on the iPhone link at index [4] to navigate to Apple'logger.debug(f'Added extracted_content to read_state_description: {action_result.extracted_content}')if action_result.long_term_memory:- action_results += f'Action {idx + 1}/{result_len} response: {action_result.long_term_memory}\n'+ action_results += f'Action {idx + 1}/{result_len}: {action_result.long_term_memory}\n'logger.debug(f'Added long_term_memory to action_results: {action_result.long_term_memory}')elif action_result.extracted_content and not action_result.include_extracted_content_only_once:- action_results += f'Action {idx + 1}/{result_len} response: {action_result.extracted_content}\n'+ action_results += f'Action {idx + 1}/{result_len}: {action_result.extracted_content}\n'logger.debug(f'Added extracted_content to action_results: {action_result.extracted_content}')if action_result.error:- action_results += f'Action {idx + 1}/{result_len} response: {action_result.error[:200]}\n'+ action_results += f'Action {idx + 1}/{result_len}: {action_result.error[:200]}\n'logger.debug(f'Added error to action_results: {action_result.error[:200]}')+ if action_results:+ action_results = f'Action Results:\n{action_results}'+ action_results = action_results.strip('\n')+# Handle case where model_output is None (e.g., parsing failed)if model_output is None:if isinstance(step_number, int) and step_number > 0:- self.agent_history_description += f"""## Step {step_number}-No model output (parsing failed)-{action_results}+ self.agent_history_description += f"""<step_{step_number}>+Agent failed to output in the right format.+</step_{step_number}>"""else:- self.agent_history_description += f"""## Step {step_number}-Step evaluation: {model_output.current_state.evaluation_previous_goal}-Step memory: {model_output.current_state.memory}-Step goal: {model_output.current_state.next_goal}+ self.agent_history_description += f"""<step_{step_number}>+Evaluation of Previous Step: {model_output.current_state.evaluation_previous_goal}+Memory: {model_output.current_state.memory}+Next Goal: {model_output.current_state.next_goal}{action_results}+</step_{step_number}>"""- if self.read_state_description == self.read_state_initialization:- self.read_state_description = ''- else:- self.read_state_description += '\nMAKE SURE TO SAVE THIS INFORMATION INTO A FILE OR TO MEMORY IF YOU NEED IT LATER.'-def _get_sensitive_data_description(self, current_page_url) -> str:sensitive_data = self.settings.sensitive_dataif not sensitive_data: