bug fix: unexpected vector store reset when Memory.delete_all() #3743
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Memory.delete_all() incorrectly wiping entire vector store collection
Problem Description
The
Memory.delete_all()method had a critical bug where it was callingself.vector_store.reset()after deleting filtered memories. This caused the entire vector store collection to be wiped, not just the memories that matched the provided filters (user_id, agent_id, run_id).Impact
delete_all(user_id="user1"), it would delete user1's memories as expected, but then wipe ALL memories from ALL usersRoot Cause
In
mem0/memory/main.py, line 1053, thedelete_all()method contained:The
self.vector_store.reset()call was incorrectly resetting the entire vector store collection after the filtered deletion.Solution
Simple Fix: Comment out the problematic
self.vector_store.reset()line.Why This Fix Is Correct
Filtered Deletion Already Works: The code above the reset call correctly:
Reset Is Unnecessary: The
reset()method is designed to clear ALL data, which contradicts the filtering behavior users expect fromdelete_all(user_id=...). According to the docs,delete_all()should only delete filtered memories (https://docs.mem0.ai/core-concepts/memory-operations/delete). Resetting the whole vector store is unexpected behavior.Consistent with Method Contract: The method signature and documentation indicate filtered deletion, not a complete reset
Changes Made
mem0/memory/main.py# self.vector_store.reset()How Has This Been Tested?
Test Results
Before/After Behavior
Before (Buggy)
After (Fixed)
Related Issues
This fix resolves the data loss issue where filtered deletions would unexpectedly wipe the entire memory collection.