Bug
When the memory search SQLite database is deleted and the gateway restarts, needsFullReindex correctly becomes true for memory files, but session files are not fully reindexed.
Root Cause
In syncSessionFiles, indexAll is computed as:
const indexAll = params.needsFullReindex || this.sessionsDirtyFiles.size === 0;
During runSafeReindex, this is called with needsFullReindex: true, which should set indexAll = true. However, the active session immediately marks itself in sessionsDirtyFiles (size becomes 1), which means on subsequent syncs (interval or search-triggered), indexAll evaluates to false since needsFullReindex is no longer true (meta now matches) and dirtyFiles.size === 1 (not 0).
The net result: after DB deletion + restart, only the currently active session gets reindexed. All other historical sessions remain unindexed until they accumulate enough new deltas to cross the dirty threshold.
Expected Behavior
Deleting the DB and restarting should result in a full reindex of all session files, not just the active one.
Workaround
Temporarily patching indexAll = ... || true in syncSessionFiles forces a full reindex. After the one-time reindex completes, revert the patch and rebuild.
Environment
- OpenClaw from source (commit
3188147f7)
- OpenAI
text-embedding-3-small embeddings
- 19 session files, only 1 (active) was being reindexed
Bug
When the memory search SQLite database is deleted and the gateway restarts,
needsFullReindexcorrectly becomestruefor memory files, but session files are not fully reindexed.Root Cause
In
syncSessionFiles,indexAllis computed as:During
runSafeReindex, this is called withneedsFullReindex: true, which should setindexAll = true. However, the active session immediately marks itself insessionsDirtyFiles(size becomes 1), which means on subsequent syncs (interval or search-triggered),indexAllevaluates tofalsesinceneedsFullReindexis no longer true (meta now matches) anddirtyFiles.size === 1(not 0).The net result: after DB deletion + restart, only the currently active session gets reindexed. All other historical sessions remain unindexed until they accumulate enough new deltas to cross the dirty threshold.
Expected Behavior
Deleting the DB and restarting should result in a full reindex of all session files, not just the active one.
Workaround
Temporarily patching
indexAll = ... || trueinsyncSessionFilesforces a full reindex. After the one-time reindex completes, revert the patch and rebuild.Environment
3188147f7)text-embedding-3-smallembeddings