mem0ai / mem0

The Memory layer for your AI apps
https://mem0.ai
Apache License 2.0
22.02k stars 2.01k forks source link

adding same memory twice deletes old memory #1674

Open munjalmukul opened 1 month ago

munjalmukul commented 1 month ago

🐛 Describe the bug

When adding exact same memory multiple times it just performs delete operation and delete previous memory.

Ideal Behaviour - None of the operation should be performed and it should not call any tool when exact same memory is added multiple times

example - Existing Memories:\n[{'id': 'fe966e90-75e1-4f3d-ac6e-be3ee3f7eaeb', 'memory': 'The dog is a domesticated descendant of the wolf. Also called the domestic dog, it was domesticated from an extinct population of Pleistocene wolves over 14,000 years ago. The dog was the first species to be domesticated by humans.', 'score': 0.99999726}]

New Memory: The dog is a domesticated descendant of the wolf. Also called the domestic dog, it was domesticated from an extinct population of Pleistocene wolves over 14,000 years ago. The dog was the first species to be domesticated by humans.

operation performed

{'content': None, 'tool_calls': [{'name': 'delete_memory', 'arguments': {'memory_id': 'fe966e90-75e1-4f3d-ac6e-be3ee3f7eaeb'}}]}

zouhuigang commented 1 month ago

Why do I only have one memory every time? It's strange. It's very easy to lose previous memories

munjalmukul commented 1 month ago

its not every time the same memory will be added but if at some point I am adding exact same memory then it should not forgot that

Dev-Khant commented 1 month ago

Hey @munjalmukul Thank you for pointing out this issue. I tried to reproduce it but couldn't get the results you got. For me, it's actually called the update_memory.

We will be working on improving the prompt here but while you find a solution please feel free to raise a PR.

munjalmukul commented 1 month ago

@Dev-Khant just observed when using gpt-4o-mini the delete operation is happing and switching to gpt-4o fixed this, but this is not a concrete solution as gpt-4o can also hallucinate and delete memory

Dev-Khant commented 1 month ago

@Dev-Khant just observed when using gpt-4o-mini the delete operation is happing and switching to gpt-4o fixed this, but this is not a concrete solution as gpt-4o can also hallucinate and delete memory

Yes you are right, we will have to improve the prompts here. Feel free to make a PR if have a better solution or else we will work on it :)

shenxiangzhuang commented 3 weeks ago

Same problem in my test. In my opinion, the memory management is the pivotal feature of mem0, and it functions effectively. However, there are lingering issues, such as this one, which perplex users. Despite relying on the library to handle memory operations, we encounter unpredictable outcomes.

Specifically, after calling mem.add(memory_info), the subsequent actions are determined by llm (via tools). Consequently, adding a new memory like I love math might result in updating I love apple to I love math, effectively deleting the memory associated with apple.

This is a complex issue that isn't easily resolved, and I simply want to emphasize it here. Hopefully, we can discover a better approach to address this.

Dev-Khant commented 3 weeks ago

@shenxiangzhuang Apologies for the trouble you encountered with this issue. We are already working on fixing on this issue and it will be released soon. Meanwhile you can the platform if it's a critical use case.