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
dont use fs for short tasks, dont initialize results.md
mertunsall35120fc25310
diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex 6637facfc..3d0fe3fd9 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -90,15 +90,12 @@ Strictly follow these rules while using the browser and navigating the web:<file_system>- You have access to a persistent file system which you can use to track progress, store results, and manage long tasks.-- Your file system is initialized with two files:- 1. `todo.md`: Use this to keep a checklist for known subtasks. Update it to mark completed items and track what remains. This file should guide your step-by-step execution when the task involves multiple known entities (e.g., a list of links or items to visit). The contents of this file will be also visible in your state. ALWAYS use `write_file` to rewrite entire `todo.md` when you want to update your progress. NEVER use `append_file` on `todo.md` as this can explode your context.- 2. `results.md`: Use this to accumulate extracted or generated results for the user. Append each new finding clearly and avoid duplication. This file serves as your output log.-- You can read, write, and append to files.+- Your file system is initialized with a `todo.md`: Use this to keep a checklist for known subtasks. Update it to mark completed items and track what remains. This file should guide your step-by-step execution when the task involves multiple known entities (e.g., a list of links or items to visit). ALWAYS use `write_file` to rewrite entire `todo.md` when you want to update your progress. NEVER use `append_file` on `todo.md` as this can explode your context.- Note that `write_file` overwrites the entire file, use it with care on existing files.- When you `append_file`, ALWAYS put newlines in the beginning and not at the end.-- If the file is too large, you are only given a preview of your file. Use read_file to see the full content if necessary.-- Always use the file system as the source of truth. Do not rely on memory alone for tracking task state.-- If exists, <available_file_paths> includes files you have downloaded or uploaded by the user. You DON'T HAVE write access to these files. You can read, upload, or share them with the user as attachment in the `done` action.+- If the file is too large, you are only given a preview of your file. Use `read_file` to see the full content if necessary.+- If exists, <available_file_paths> includes files you have downloaded or uploaded by the user. You can only read or upload these files but you don't have write access.+- If the task is really long, initialize a `results.md` file to accumulate your results.- DO NOT use the file system if the task is less than 5 steps!</file_system>diff --git a/browser_use/agent/system_prompt_no_thinking.md b/browser_use/agent/system_prompt_no_thinking.mdindex 36d2c8698..60a470a61 100644--- a/browser_use/agent/system_prompt_no_thinking.md+++ b/browser_use/agent/system_prompt_no_thinking.md@@ -90,15 +90,12 @@ Strictly follow these rules while using the browser and navigating the web:<file_system>- You have access to a persistent file system which you can use to track progress, store results, and manage long tasks.-- Your file system is initialized with two files:- 1. `todo.md`: Use this to keep a checklist for known subtasks. Update it to mark completed items and track what remains. This file should guide your step-by-step execution when the task involves multiple known entities (e.g., a list of links or items to visit). The contents of this file will be also visible in your state. ALWAYS use `write_file` to rewrite entire `todo.md` when you want to update your progress. NEVER use `append_file` on `todo.md` as this can explode your context.- 2. `results.md`: Use this to accumulate extracted or generated results for the user. Append each new finding clearly and avoid duplication. This file serves as your output log.-- You can read, write, and append to files.+- Your file system is initialized with a `todo.md`: Use this to keep a checklist for known subtasks. Update it to mark completed items and track what remains. This file should guide your step-by-step execution when the task involves multiple known entities (e.g., a list of links or items to visit). ALWAYS use `write_file` to rewrite entire `todo.md` when you want to update your progress. NEVER use `append_file` on `todo.md` as this can explode your context.- Note that `write_file` overwrites the entire file, use it with care on existing files.- When you `append_file`, ALWAYS put newlines in the beginning and not at the end.-- If the file is too large, you are only given a preview of your file. Use read_file to see the full content if necessary.-- Always use the file system as the source of truth. Do not rely on memory alone for tracking task state.+- If the file is too large, you are only given a preview of your file. Use `read_file` to see the full content if necessary.- If exists, <available_file_paths> includes files you have downloaded or uploaded by the user. You can only read or upload these files but you don't have write access.+- If the task is really long, initialize a `results.md` file to accumulate your results.- DO NOT use the file system if the task is less than 5 steps!</file_system>diff --git a/browser_use/filesystem/file_system.py b/browser_use/filesystem/file_system.pyindex c4a97e18a..eb823e9fd 100644--- a/browser_use/filesystem/file_system.py+++ b/browser_use/filesystem/file_system.py@@ -124,7 +124,7 @@ class FileSystem:self.files = {}if create_default_files:- self.default_files = ['results.md', 'todo.md']+ self.default_files = ['todo.md']self._create_default_files()self.extracted_content_count = 0diff --git a/tests/ci/test_filesystem.py b/tests/ci/test_filesystem.pyindex 5f9a9b017..b005c432d 100644--- a/tests/ci/test_filesystem.py+++ b/tests/ci/test_filesystem.py@@ -138,14 +138,11 @@ class TestFileSystem:assert fs.data_dir.name == DEFAULT_FILE_SYSTEM_PATH# Check default files are created- assert 'results.md' in fs.filesassert 'todo.md' in fs.files- assert len(fs.files) == 2+ assert len(fs.files) == 1# Check files exist on disk- results_path = fs.data_dir / 'results.md'todo_path = fs.data_dir / 'todo.md'- assert results_path.exists()assert todo_path.exists()def test_filesystem_without_default_files(self, empty_filesystem):@@ -199,12 +196,6 @@ class TestFileSystem:"""Test getting files from the filesystem."""fs = temp_filesystem- # Get existing file- results_file = fs.get_file('results.md')- assert results_file is not None- assert isinstance(results_file, MarkdownFile)- assert results_file.name == 'results'-# Get non-existent filenon_existent = fs.get_file('nonexistent.md')assert non_existent is None@@ -218,16 +209,15 @@ class TestFileSystem:fs = temp_filesystemfiles = fs.list_files()- assert 'results.md' in filesassert 'todo.md' in files- assert len(files) == 2+ assert len(files) == 1def test_display_file(self, temp_filesystem):"""Test displaying file content."""fs = temp_filesystem# Display existing file- content = fs.display_file('results.md')+ content = fs.display_file('todo.md')assert content == '' # Default files are empty# Display non-existent file@@ -243,8 +233,8 @@ class TestFileSystem:fs = temp_filesystem# Read existing empty file- result = fs.read_file('results.md')- expected = 'Read from file results.md.\n<content>\n\n</content>'+ result = fs.read_file('todo.md')+ expected = 'Read from file todo.md.\n<content>\n\n</content>'assert result == expected# Read non-existent file@@ -326,17 +316,6 @@ class TestFileSystem:assert content1 == 'First extracted content'assert content2 == 'Second extracted content'- async def test_describe_empty_files(self, temp_filesystem):- """Test describing filesystem with empty files."""- fs = temp_filesystem-- description = fs.describe()-- # Should contain results.md but not todo.md (excluded from description)- assert 'results.md' in description- assert 'todo.md' not in description- assert '[empty file]' in description-async def test_describe_with_content(self, temp_filesystem):"""Test describing filesystem with files containing content."""fs = temp_filesystem@@ -392,15 +371,8 @@ class TestFileSystem:assert isinstance(state, FileSystemState)assert state.base_dir == str(fs.base_dir)assert state.extracted_content_count == 0- assert 'results.md' in state.filesassert 'todo.md' in state.files- # Check file data structure- results_data = state.files['results.md']- assert results_data['type'] == 'MarkdownFile'- assert 'data' in results_data- assert results_data['data']['name'] == 'results'-async def test_from_state(self, temp_filesystem):"""Test restoring filesystem from state."""fs = temp_filesystem@@ -503,7 +475,6 @@ class TestFileSystemEdgeCases:# Custom file should be gone, default files should existassert not custom_file.exists()- assert (fs2.data_dir / 'results.md').exists()assert (fs2.data_dir / 'todo.md').exists()fs2.nuke()