fix(ts-sdk): default historyDbPath to ~/.mem0/history.db instead of r…#5007
fix(ts-sdk): default historyDbPath to ~/.mem0/history.db instead of r…#5007shafdev wants to merge 1 commit intomem0ai:mainfrom
Conversation
…elative memory.db Fixes mem0ai#5004 The default historyDbPath in DEFAULT_MEMORY_CONFIG was set to the bare relative string "memory.db", which caused better-sqlite3 to resolve it against the current working directory. Running any CLI command (e.g. via openclaw-mem0) from different directories created a fresh memory.db file in each CWD. Fix mirrors the existing getDefaultVectorStoreDbPath() pattern: - Add getDefaultHistoryDbPath() → ~/.mem0/history.db in utils/sqlite.ts - Use it in config/defaults.ts instead of the bare relative literal - Update 2 test assertions that checked for the old "memory.db" default Explicitly passed historyDbPath values (relative or absolute) are unaffected — the config cascade precedence is unchanged.
PHclaw
left a comment
There was a problem hiding this comment.
Nice fix! Using ~/.mem0/history.db as default is much better than a relative path.
One suggestion: consider using os.path.expanduser() explicitly in case the runtime doesn't expand ~:
default_path = os.path.expanduser('~/.mem0/history.db')Also, it would be good to ensure the parent directory exists:
os.makedirs(os.path.dirname(default_path), exist_ok=True)This prevents FileNotFoundError on first run.
|
Thanks for taking a look! Both points are already handled in the current implementation:
For reference, the Python SDK does the equivalent — |
Linked Issue
Closes #5004
Description
Default historyDbPath was set to "memory.db" (relative), causing
better-sqlite3 to create a fresh SQLite file in every CWD. Mirrors the
existing getDefaultVectorStoreDbPath() pattern — now defaults to
~/.mem0/history.db.
Type of Change
Breaking Changes
N/A
Test Coverage
Checklist