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 file display logic in service.py to improve user message formatting. Consolidated file content messages into a single variable and added a warning for cases where no files are found, enhancing clarity and user feedback.
Magnus Müller347649e59f6f
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex 638ffe397..b4e9ea265 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -90,13 +90,18 @@ class Controller(Generic[Context]):memory += f' - {len_text - len_max_memory} more characters'if params.files_to_display:- user_message += '\n\nBelow are the files I saved for you:'+ file_msg = ''for file_name in params.files_to_display:if file_name == 'todo.md':continuefile_content = file_system.display_file(file_name)if file_content:- user_message += f'\n\n{file_name}:\n{file_content}'+ file_msg += f'\n\n{file_name}:\n{file_content}'+ if file_msg:+ user_message += '\n\nBelow are the files I saved for you:'+ user_message += file_msg+ else:+ logger.warning('Agent wanted to display files but none were found')return ActionResult(is_done=True, success=params.success, extracted_content=user_message, memory=memory)