Skip to content

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

Improve error logging in action results

Magnus Müllerbfb2083adbef
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.py
index b48d1aff1..c80938d1a 100644
--- a/browser_use/agent/message_manager/service.py
+++ b/browser_use/agent/message_manager/service.py
@@ -247,8 +247,9 @@ The file system actions do not change the browser state, so I can also click on
logger.debug(f'Added extracted_content to action_results: {action_result.extracted_content}')
if action_result.error:
- action_results += f'Action {idx + 1}/{result_len}: {action_result.error[:200]}\n'
- logger.debug(f'Added error to action_results: {action_result.error[:200]}')
+ error_text = action_result.error[:100] + '...' + action_result.error[-100:]
+ action_results += f'Action {idx + 1}/{result_len}: {error_text}\n'
+ logger.debug(f'Added error to action_results: {error_text}')
if action_results:
action_results = f'Action Results:\n{action_results}'