Skip to content

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

Fix potential error message duplicate

Magnus Müller5ce6d2397664
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.py
index c80938d1a..9979c8cc4 100644
--- a/browser_use/agent/message_manager/service.py
+++ b/browser_use/agent/message_manager/service.py
@@ -247,7 +247,10 @@ 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:
- error_text = action_result.error[:100] + '...' + action_result.error[-100:]
+ if len(action_result.error) > 200:
+ error_text = action_result.error[:100] + '...' + action_result.error[-100:]
+ else:
+ error_text = action_result.error
action_results += f'Action {idx + 1}/{result_len}: {error_text}\n'
logger.debug(f'Added error to action_results: {error_text}')