Skip to content

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

add assertion for safety

mertunsall729fc798ca82
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.py
index 504b842d7..b48d1aff1 100644
--- a/browser_use/agent/message_manager/service.py
+++ b/browser_use/agent/message_manager/service.py
@@ -116,6 +116,8 @@ class MessageManager:
self.use_thinking = use_thinking
self.max_history_items = max_history_items
+ assert max_history_items is None or max_history_items > 5, 'max_history_items must be None or greater than 5'
+
# Store settings as direct attributes instead of in a settings object
self.include_attributes = include_attributes or []
self.message_context = message_context