Skip to content

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

fix long error messages

mertunsall4955cc00c852
diff --git a/browser_use/browser/default_action_watchdog.py b/browser_use/browser/default_action_watchdog.py
index 5b5889867..c869ac4b4 100644
--- a/browser_use/browser/default_action_watchdog.py
+++ b/browser_use/browser/default_action_watchdog.py
@@ -248,7 +248,7 @@ class DefaultActionWatchdog(BaseWatchdog):
if tag_name == 'input' and element_type == 'file':
raise Exception(
- '<llm_error_msg>Cannot click on file input elements. File uploads must be handled using upload_file_to_element()</llm_error_msg>'
+ f'<llm_error_msg>Cannot click on file input element (index={element_node.element_index}). File uploads must be handled using upload_file_to_element action</llm_error_msg>'
)
# Get CDP client
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 81d63af29..bbe0534ca 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -1092,7 +1092,9 @@ Provide the extracted information in a clear, structured format."""
context=context,
)
except Exception as e:
- result = ActionResult(error=str(e))
+ # Extract clean error message from llm_error_msg tags if present
+ clean_msg = extract_llm_error_message(e)
+ result = ActionResult(error=clean_msg)
if Laminar is not None:
Laminar.set_span_output(result)