Skip to content

Self-hosted AI workspace.

Python

Rebuild memory vector index from the full saved set, not just the audited owner (#1747)

pewdiepie-archdaemon8332b83ef6cd
diff --git a/services/memory/memory_extractor.py b/services/memory/memory_extractor.py
index c994bb9a2..f31dc7c2f 100644
--- a/services/memory/memory_extractor.py
+++ b/services/memory/memory_extractor.py
@@ -547,17 +547,20 @@ async def audit_memories(
for e in all_entries:
if e.get("owner") is None and e["id"] not in audited_ids and e["id"] not in {o["id"] for o in other_entries}:
other_entries.append(e)
- memory_manager.save(final_entries + other_entries)
+ saved_entries = final_entries + other_entries
else:
- memory_manager.save(final_entries)
+ saved_entries = final_entries
+ memory_manager.save(saved_entries)
logger.info(
f"Memory audit complete: {before_count} -> {after_count} entries "
f"({before_count - after_count} removed/merged)"
)
- # Rebuild vector index
+ # Rebuild vector index from the full saved set, not just this owner's
+ # slice — otherwise the shared collection is wiped of every other
+ # owner's entries until they happen to run their own audit.
if memory_vector and memory_vector.healthy:
- memory_vector.rebuild(final_entries)
+ memory_vector.rebuild(saved_entries)
# Persist the post-tidy fingerprint so the next call short-circuits
# if nothing has changed in the meantime.