The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
Fix/new mem mistaken for current fixing #2875 (#2876)
John Lockwood97fd320bbff7
diff --git a/mem0/configs/prompts.py b/mem0/configs/prompts.pyindex b8daecfd6..fbfbe7f6f 100644--- a/mem0/configs/prompts.py+++ b/mem0/configs/prompts.py@@ -293,14 +293,26 @@ def get_update_memory_messages(retrieved_old_memory_dict, response_content, custglobal DEFAULT_UPDATE_MEMORY_PROMPTcustom_update_memory_prompt = DEFAULT_UPDATE_MEMORY_PROMPT- return f"""{custom_update_memory_prompt}+ if retrieved_old_memory_dict:+ current_memory_part = f"""Below is the current content of my memory which I have collected till now. You have to update it in the following format only:```{retrieved_old_memory_dict}```+ """+ else:+ current_memory_part = """+ Current memory is empty.++ """++ return f"""{custom_update_memory_prompt}++ {current_memory_part}+The new retrieved facts are mentioned in the triple backticks. You have to analyze the new retrieved facts and determine whether these facts should be added, updated, or deleted in the memory.```diff --git a/tests/configs/test_prompts.py b/tests/configs/test_prompts.pyindex e978f8c9f..1376ab181 100644--- a/tests/configs/test_prompts.py+++ b/tests/configs/test_prompts.py@@ -17,3 +17,35 @@ def test_get_update_memory_messages():##result = prompts.get_update_memory_messages(retrieved_old_memory_dict, response_content, None)assert result.startswith(prompts.DEFAULT_UPDATE_MEMORY_PROMPT)+++def test_get_update_memory_messages_empty_memory():+ # Test with None for retrieved_old_memory_dict+ result = prompts.get_update_memory_messages(+ None,+ ["new fact"],+ None+ )+ assert "Current memory is empty" in result++ # Test with empty list for retrieved_old_memory_dict+ result = prompts.get_update_memory_messages(+ [],+ ["new fact"],+ None+ )+ assert "Current memory is empty" in result+++def test_get_update_memory_messages_non_empty_memory():+ # Non-empty memory scenario+ memory_data = [{"id": "1", "text": "existing memory"}]+ result = prompts.get_update_memory_messages(+ memory_data,+ ["new fact"],+ None+ )+ # Check that the memory data is displayed+ assert str(memory_data) in result+ # And that the non-empty memory message is present+ assert "current content of my memory" in result