Skip to content

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

make markdownify non-blocking async

Nick Sweetinga8eb2bac2f01
diff --git a/browser_use/agent/memory/service.py b/browser_use/agent/memory/service.py
index 4c12dc92f..34b100bc2 100644
--- a/browser_use/agent/memory/service.py
+++ b/browser_use/agent/memory/service.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import logging
import os
import warnings
+from concurrent.futures import ThreadPoolExecutor, TimeoutError
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.messages import (
@@ -137,8 +138,17 @@ class Memory:
if len(messages_to_process) <= 1:
self.logger.debug('πŸ“œ Not enough non-memory messages to summarize')
return
- # Create a procedural memory
- memory_content = self._create([m.message for m in messages_to_process], current_step)
+ # Create a procedural memory with timeout
+ try:
+ with ThreadPoolExecutor(max_workers=1) as executor:
+ future = executor.submit(self._create, [m.message for m in messages_to_process], current_step)
+ memory_content = future.result(timeout=5)
+ except TimeoutError:
+ self.logger.warning('πŸ“œ Procedural memory creation timed out after 30 seconds')
+ return
+ except Exception as e:
+ self.logger.error(f'πŸ“œ Error during procedural memory creation: {e}')
+ return
if not memory_content:
self.logger.warning('πŸ“œ Failed to create procedural memory')