memory-lancedb-pro icon indicating copy to clipboard operation
memory-lancedb-pro copied to clipboard

canonicalCorpus never indexes: sync() is never invoked, and workspace resolution reads agents.list instead of agents.entries

Open benjaml4 opened this issue 4 months ago • 1 comments

Plugin version: 1.1.0-beta.11 (master) OpenClaw: 2026.7.2-beta.6 Config: canonicalCorpus.enabled: true, syncOnSearch: true

With canonicalCorpus.enabled: true the in-place index silently stayed empty forever. Two independent causes.

1. canonicalCorpusIndexer.sync() is never called

dist/index.js constructs the indexer but never calls .sync(). The only call sites are in src/openclaw-memory-capability.js:

  • the capability's search() (gated on canonicalCorpus.syncOnSearch)
  • the capability's sync()

Both are only reachable when the host drives the memory capability via getActiveMemorySearchManager. But the plugin also registers its own memory_search / memory_get tools, so agent searches resolve to those tools and never touch the capability. Net result: the canonical corpus never indexes, with no error and no log.

Reproduce: enable canonicalCorpus, own the memory slot, restart, run a memory_search from an agent — the store gains no corpus: rows.

Suggested fix: kick a fire-and-forget sync() when the plugin service starts, and/or drive it on a timer from syncIntervalMs.

2. resolveCanonicalCorpusWorkspaces reads agents.list, but OpenClaw uses agents.entries

src/corpus-indexer.js:

const list = Array.isArray(agents?.list) ? agents.list : [];
for (const entry of list) { ... add(entry.workspace ?? ..., entry.id); }

OpenClaw stores agents as an object keyed by agent id under agents.entries, not an array under agents.list. The loop therefore matches nothing and the function falls through to its single-workspace fallback:

byWorkspace.set(join(homeDir, ".openclaw", "workspace"), new Set(["main"]));

So only the default workspace is ever indexed. In my case that silently missed 5 of 6 agent workspaces — and because the fallback "works", there is no symptom suggesting anything is wrong.

Supporting both shapes fixes it. After patching, resolveCanonicalCorpusWorkspaces returns all 6 workspaces and a sync reports:

indexed 2505/2505 canonical corpus chunk(s), 0 stale (startup) — from 796 document(s)

Happy to send a PR for either or both if useful.

benjaml4 avatar Aug 03 '26 15:08 benjaml4

Confirmed both on current master:

  1. No sync driver. canonicalCorpusIndexer.sync() is only called from src/openclaw-memory-capability.ts (capability search() with syncOnSearch, and capability sync()). Nothing in index.ts triggers it at service start or on syncIntervalMs. So when agents use the plugin's own memory_search tool, the corpus never indexes.
  2. agents.list only. resolveCanonicalCorpusWorkspaces() in src/corpus-indexer.ts still reads only agents.list. Note that src/session-recovery.ts and the md-mirror path in index.ts (collectAgentWorkspaces(parsed?.agents?.entries, …)) already handle the agents.entries object form, so there's an existing pattern to reuse.

Both are real bugs, so yes, please send the PR. Splitting it in two would make review easier: (2) is a small, self-contained fix, while (1) needs a decision on start-up vs. timer-driven sync. Please add a regression test for each.

AliceLJY avatar Oct 27 '26 09:10 AliceLJY