From 85bc18b7d806e5e1885a2ca439a65e562b910db5 Mon Sep 17 00:00:00 2001 From: Stephen Purdue <79877277+stephendpurdue@users.noreply.github.com> Date: Wed, 3 Jun 2026 06:12:24 +0100 Subject: [PATCH] fix: fixed minor consistency issues within MemoryManager (#1353) --- services/memory/memory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/memory/memory.py b/services/memory/memory.py index 0f092db..69be755 100644 --- a/services/memory/memory.py +++ b/services/memory/memory.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) def tokenize(text: str) -> List[str]: """Simple tokenizer that splits on whitespace and removes punctuation.""" - return [word.strip('.,!?";') for word in text.split()] + return [cleaned for word in text.split() if (cleaned := word.strip('.,!?";'))] def get_text_similarity(text1: str, text2: str) -> float: """Calculate Jaccard similarity between two texts.""" @@ -70,7 +70,7 @@ class MemoryManager: if text: memories.append({ "text": text, - "timestamp": int(datetime.now().timestamp()), + "timestamp": int(time.time()), "session_id": session_id }) # If we see a heading that suggests memories @@ -105,6 +105,7 @@ class MemoryManager: def ensure_file_exists(self): """Create memory file if it doesn't exist.""" if not os.path.exists(self.memory_file): + os.makedirs(os.path.dirname(self.memory_file), exist_ok=True) with open(self.memory_file, 'w', encoding='utf-8') as f: json.dump([], f, ensure_ascii=False, indent=2)