#1 Persistent memory for AI coding agents based on real-world benchmarks
TypeScript agentmemoryagentsaiclaudeclaudecodecodexcopilotcursorgenaiharnesshermesmemoryompopenclawopencodepi
fix(boot): make rebuildIndex non-blocking so viewer + later boot steps run (#500)
efenexc6a1fec2f183
diff --git a/src/index.ts b/src/index.tsindex 630475c2..704d4809 100644--- a/src/index.ts+++ b/src/index.ts@@ -412,16 +412,24 @@ async function main() {const needsRebuild = bm25Index.size === 0;if (needsRebuild) {- const indexCount = await rebuildIndex(kv).catch((err) => {- console.warn(`[agentmemory] Failed to rebuild search index:`, err);- return 0;- });- if (indexCount > 0) {- bootLog(- `Search index rebuilt: ${indexCount} entries`,- );- indexPersistence.scheduleSave();- }+ // Fire-and-forget. rebuildIndex iterates every observation across+ // every session and AWAITS an embedding-provider call per record.+ // On a large corpus + rate-limited embedding endpoint that can+ // take HOURS; awaiting it here blocks every subsequent boot step+ // (including startViewerServer below, leaving the viewer port+ // unbound for the duration). The index lazily fills in over time+ // and search degrades gracefully — partial coverage > no viewer+ // for hours. Errors still surface via the inner .catch.+ void rebuildIndex(kv)+ .then((indexCount) => {+ if (indexCount > 0) {+ bootLog(`Search index rebuilt: ${indexCount} entries`);+ indexPersistence.scheduleSave();+ }+ })+ .catch((err) => {+ console.warn(`[agentmemory] Failed to rebuild search index:`, err);+ });} else {// Backfill memories into BM25 for users upgrading from <0.9.5: prior// versions of mem::remember never indexed memories, so the persisted