🐛 Describe the Bug
When using Qdrant with local path storage, all data is silently deleted on every program restart if on_disk is not explicitly set to True.
🔍 Root Cause
In mem0/vector_stores/qdrant.py lines 62-67:
if not params: # Local path mode
params["path"] = path
self.is_local = True
if not on_disk: # Defaults to False!
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path) # ← Deletes all persisted data!
When on_disk is False (the default), the code unconditionally calls shutil.rmtree(path) to wipe the entire storage directory on every initialization. This means any data saved in a previous session is silently destroyed.
✅ Expected Behavior
Local storage should persist across restarts by default, or at minimum warn users clearly about this destructive behavior before deleting data.
❌ Actual Behavior
All memories are silently deleted every time Memory.from_config() is called without on_disk: True.
🔄 Steps to Reproduce
from mem0 import Memory
config = {
"vector_store": {
"provider": "qdrant",
"config": {
"collection_name": "memories",
"path": "./qdrant_storage",
"embedding_model_dims": 1024,
# "on_disk": True # ← Not specified, defaults to False!
}
}
}
# First run
m = Memory.from_config(config)
m.add("My name is Alice", user_id="alice")
print(m.get_all(user_id="alice")) # Shows 1 memory
# Restart program...
# Second run - data is gone!
m = Memory.from_config(config) # ← Silently deletes ./qdrant_storage/
print(m.get_all(user_id="alice")) # Empty!
💡 Proposed Solutions
Option A (Recommended): Change default on_disk to True when path is specified:
# In qdrant.py __init__
if not on_disk and path:
on_disk = True # Auto-enable persistence for local storage
Option B: Never auto-delete existing directories; only create a fresh collection if explicitly requested via a new reset=True parameter:
if reset and os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path)
Option C: At minimum, add a prominent warning log before deletion so users are not caught off guard.
📋 Environment
- Mem0 version: 0.1.0+
- Python: 3.8+
- OS: Any (tested on Windows 11, Linux)
🔗 Related Issues
🐛 Describe the Bug
When using Qdrant with local
pathstorage, all data is silently deleted on every program restart ifon_diskis not explicitly set toTrue.🔍 Root Cause
In
mem0/vector_stores/qdrant.pylines 62-67:When
on_diskisFalse(the default), the code unconditionally callsshutil.rmtree(path)to wipe the entire storage directory on every initialization. This means any data saved in a previous session is silently destroyed.✅ Expected Behavior
Local storage should persist across restarts by default, or at minimum warn users clearly about this destructive behavior before deleting data.
❌ Actual Behavior
All memories are silently deleted every time
Memory.from_config()is called withouton_disk: True.🔄 Steps to Reproduce
💡 Proposed Solutions
Option A (Recommended): Change default
on_disktoTruewhenpathis specified:Option B: Never auto-delete existing directories; only create a fresh collection if explicitly requested via a new
reset=Trueparameter:Option C: At minimum, add a prominent warning log before deletion so users are not caught off guard.
📋 Environment
🔗 Related Issues
new_memories_with_actionswhile usingQdrantLocal#1989 (useson_disk: Trueas workaround)