Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Enhance error messages for unavailable file paths in Tools class. Updated messages to provide clear instructions for users on how to add file paths to the available_file_paths parameter when creating an Agent. This improves user guidance and error handling for file uploads.

Magnus Müller0ba26ae9fb0a
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index f77bfa726..917b31107 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -383,7 +383,7 @@ class Tools(Generic[Context]):
if not browser_session.is_local:
pass
else:
- msg = f'File path {params.path} is not available. Upload files must be in available_file_paths, downloaded_files, or a file managed by file_system.'
+ msg = f'File path {params.path} is not available. To fix: The user must add this file path to the available_file_paths parameter when creating the Agent. Example: Agent(task="...", llm=llm, browser=browser, available_file_paths=["{params.path}"])'
logger.error(f'❌ {msg}')
return ActionResult(error=msg)
else:
@@ -391,7 +391,7 @@ class Tools(Generic[Context]):
if not browser_session.is_local:
pass
else:
- msg = f'File path {params.path} is not available. Upload files must be in available_file_paths, downloaded_files, or a file managed by file_system.'
+ msg = f'File path {params.path} is not available. To fix: The user must add this file path to the available_file_paths parameter when creating the Agent. Example: Agent(task="...", llm=llm, browser=browser, available_file_paths=["{params.path}"])'
raise BrowserError(message=msg, long_term_memory=msg)
# For local browsers, ensure the file exists on the local filesystem
@@ -1504,7 +1504,7 @@ class CodeAgentTools(Tools[Context]):
if not browser_session.is_local:
pass
else:
- msg = f'File path {params.path} is not available. Upload files must be in available_file_paths, downloaded_files, or a file managed by file_system.'
+ msg = f'File path {params.path} is not available. To fix: add this file path to the available_file_paths parameter when creating the Agent. Example: Agent(task="...", llm=llm, browser=browser, available_file_paths=["{params.path}"])'
logger.error(f'❌ {msg}')
return ActionResult(error=msg)
else:
@@ -1512,7 +1512,7 @@ class CodeAgentTools(Tools[Context]):
if not browser_session.is_local:
pass
else:
- msg = f'File path {params.path} is not available. Upload files must be in available_file_paths or downloaded_files.'
+ msg = f'File path {params.path} is not available. To fix: add this file path to the available_file_paths parameter when creating the Agent. Example: Agent(task="...", llm=llm, browser=browser, available_file_paths=["{params.path}"])'
logger.error(f'❌ {msg}')
return ActionResult(error=msg)