Skip to content

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

Description

@benjaml4

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions