Skip to content

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

Save last state in message manager

Magnus Müller3c5fbe9eb56b
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.py
index 576546428..baf0931a4 100644
--- a/browser_use/agent/message_manager/service.py
+++ b/browser_use/agent/message_manager/service.py
@@ -125,6 +125,7 @@ class MessageManager:
self.sensitive_data_description = ''
self.available_file_paths = available_file_paths
self.use_thinking = use_thinking
+ self.last_input_messages = []
# Only initialize messages if state is empty
if len(self.state.history.messages) == 0:
self._init_messages()
@@ -392,8 +393,8 @@ Next Goal: {model_output.current_state.next_goal}
# Log message history for debugging
logger.debug(self._log_history_lines())
-
- return [m.message for m in self.state.history.messages]
+ self.last_input_messages = [m.message for m in self.state.history.messages]
+ return self.last_input_messages
def _add_message_with_type(
self,