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
fixes based on evals
mertunsall92da75520bb3
diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.mdindex a4fc2861d..d22a35b75 100644--- a/browser_use/agent/system_prompt.md+++ b/browser_use/agent/system_prompt.md@@ -159,8 +159,8 @@ Here are examples of good output patterns. Use them as reference but never copy<todo_examples>"write_file": {{- "content": "# ArXiv CS.AI Recent Papers Collection Task\n\n## Goal: Collect metadata for 20 most recent papers\n\n## Tasks:\n- [x] Navigate to https://arxiv.org/list/cs.AI/recent\n- [x] Initialize papers.md file for storing paper data\n- [x] Collect paper 1/20: The Automated LLM Speedrunning Benchmark\n- [x] Collect paper 2/20: AI Model Passport\n- [x] Collect paper 3/20: Embodied AI Agents\n- [x] Collect paper 4/20: Conceptual Topic Aggregation\n- [x] Collect paper 5/20: Artificial Intelligent Disobedience\n- [ ] Continue collecting remaining papers from current page\n- [ ] Navigate through subsequent pages if needed\n- [ ] Continue until 20 papers are collected\n- [ ] Verify all 20 papers have complete metadata\n- [ ] Final review and completion\n\n## Progress:\n- Papers collected: 5/20\n- Current page: First page (showing 1-50 of 134 entries)\n- Next: Scroll down to see more papers on current page","file_name": "todo.md",+ "content": "# ArXiv CS.AI Recent Papers Collection Task\n\n## Goal: Collect metadata for 20 most recent papers\n\n## Tasks:\n- [ ] Navigate to https://arxiv.org/list/cs.AI/recent\n- [ ] Initialize papers.md file for storing paper data\n- [ ] Collect paper 1/20: The Automated LLM Speedrunning Benchmark\n- [x] Collect paper 2/20: AI Model Passport\n- [ ] Collect paper 3/20: Embodied AI Agents\n- [ ] Collect paper 4/20: Conceptual Topic Aggregation\n- [ ] Collect paper 5/20: Artificial Intelligent Disobedience\n- [ ] Continue collecting remaining papers from current page\n- [ ] Navigate through subsequent pages if needed\n- [ ] Continue until 20 papers are collected\n- [ ] Verify all 20 papers have complete metadata\n- [ ] Final review and completion"}}</todo_examples>diff --git a/browser_use/agent/system_prompt_no_thinking.md b/browser_use/agent/system_prompt_no_thinking.mdindex 7401bf55e..226f142bd 100644--- a/browser_use/agent/system_prompt_no_thinking.md+++ b/browser_use/agent/system_prompt_no_thinking.md@@ -157,8 +157,8 @@ Here are examples of good output patterns. Use them as reference but never copy<todo_examples>"write_file": {{- "content": "# ArXiv CS.AI Recent Papers Collection Task\n\n## Goal: Collect metadata for 20 most recent papers\n\n## Tasks:\n- [x] Navigate to https://arxiv.org/list/cs.AI/recent\n- [x] Initialize papers.md file for storing paper data\n- [x] Collect paper 1/20: The Automated LLM Speedrunning Benchmark\n- [x] Collect paper 2/20: AI Model Passport\n- [x] Collect paper 3/20: Embodied AI Agents\n- [x] Collect paper 4/20: Conceptual Topic Aggregation\n- [x] Collect paper 5/20: Artificial Intelligent Disobedience\n- [ ] Continue collecting remaining papers from current page\n- [ ] Navigate through subsequent pages if needed\n- [ ] Continue until 20 papers are collected\n- [ ] Verify all 20 papers have complete metadata\n- [ ] Final review and completion\n\n## Progress:\n- Papers collected: 5/20\n- Current page: First page (showing 1-50 of 134 entries)\n- Next: Scroll down to see more papers on current page","file_name": "todo.md",+ "content": "# ArXiv CS.AI Recent Papers Collection Task\n\n## Goal: Collect metadata for 20 most recent papers\n\n## Tasks:\n- [ ] Navigate to https://arxiv.org/list/cs.AI/recent\n- [ ] Initialize papers.md file for storing paper data\n- [ ] Collect paper 1/20: The Automated LLM Speedrunning Benchmark\n- [x] Collect paper 2/20: AI Model Passport\n- [ ] Collect paper 3/20: Embodied AI Agents\n- [ ] Collect paper 4/20: Conceptual Topic Aggregation\n- [ ] Collect paper 5/20: Artificial Intelligent Disobedience\n- [ ] Continue collecting remaining papers from current page\n- [ ] Navigate through subsequent pages if needed\n- [ ] Continue until 20 papers are collected\n- [ ] Verify all 20 papers have complete metadata\n- [ ] Final review and completion"}}</todo_examples>diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex f2a406f74..6b650f3c4 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -22,7 +22,6 @@ from browser_use.controller.views import (ClickElementAction,CloseTabAction,DoneAction,- FileStrReplaceAction,GoToUrlAction,InputTextAction,NoParamsAction,@@ -32,7 +31,6 @@ from browser_use.controller.views import (StructuredOutputAction,SwitchTabAction,UploadFileAction,- WriteFileAction,)from browser_use.filesystem.file_system import FileSystemfrom browser_use.llm.base import BaseChatModel@@ -748,24 +746,30 @@ Explain the content of the page and that the requested information is not availa@self.registry.action('Write or append content to file_name in file system. Allowed extensions are .md, .txt, .json, .csv, .pdf. For .pdf files, write the content in markdown format and it will automatically be converted to a properly formatted PDF document.')- async def write_file(params: WriteFileAction, file_system: FileSystem):- content = params.content- if params.trailing_newline:+ async def write_file(+ file_name: str,+ content: str,+ file_system: FileSystem,+ append: bool = False,+ trailing_newline: bool = True,+ leading_newline: bool = False,+ ):+ if trailing_newline:content += '\n'- if params.leading_newline:+ if leading_newline:content = '\n' + content- if params.append:- result = await file_system.append_file(params.file_name, content)+ if append:+ result = await file_system.append_file(file_name, content)else:- result = await file_system.write_file(params.file_name, content)+ result = await file_system.write_file(file_name, content)logger.info(f'💾 {result}')return ActionResult(extracted_content=result, include_in_memory=True, long_term_memory=result)@self.registry.action('Replace old_str with new_str in file_name. old_str must exactly match the string to replace in original text. Recommended tool to mark completed items in todo.md or change specific contents in a file.')- async def replace_file_str(params: FileStrReplaceAction, file_system: FileSystem):- result = await file_system.replace_file_str(params.file_name, params.old_str, params.new_str)+ async def replace_file_str(file_name: str, old_str: str, new_str: str, file_system: FileSystem):+ result = await file_system.replace_file_str(file_name, old_str, new_str)logger.info(f'💾 {result}')return ActionResult(extracted_content=result, include_in_memory=True, long_term_memory=result)diff --git a/browser_use/controller/views.py b/browser_use/controller/views.pyindex 57d6b46d9..aa4512e32 100644--- a/browser_use/controller/views.py+++ b/browser_use/controller/views.py@@ -71,17 +71,3 @@ class NoParamsAction(BaseModel):model_config = ConfigDict(extra='ignore')# No fields defined - all inputs are ignored automatically---class WriteFileAction(BaseModel):- file_name: str- content: str- append: bool = False- trailing_newline: bool = True- leading_newline: bool = False---class FileStrReplaceAction(BaseModel):- file_name: str- old_str: str- new_str: str