Skip to content

fix(memory): make local long-term memory work once models are configured - #66

Merged
Luhaozhu merged 1 commit into
mainfrom
fix/local-memory-bootstrap
Aug 5, 2026
Merged

fix(memory): make local long-term memory work once models are configured#66
Luhaozhu merged 1 commit into
mainfrom
fix/local-memory-bootstrap

Conversation

@Luhaozhu

@Luhaozhu Luhaozhu commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Stale mem0 singleton: saving the memory/embedding model config only invalidated the resolve cache; an instance initialized against the placeholder key kept failing 401 forever. Config routes now reset the memory runtime, and credential errors self-heal by rebuilding the singleton (excluded from the Milvus circuit breaker).
  • CE audit stub signature: the stub rejected the real implementation's positional call style, raising after the DB commit and mis-reporting successful L1 writes as failures (no write card in the UI). Now accepts any call shape, with a contract regression test.
  • Vector dimension mismatch: collections were created at the configured dimension (default 1024) while embedders return their native width (e.g. 4096). Init now probes the real dimension via one /embeddings call; an existing empty mismatched collection is dropped and rebuilt, a non-empty one (embedding-model switch) is fully re-embedded with the new model before the swap — old data survives if the new model is unreachable.
  • Missing local tables: the CE models facade didn't import the evolution models or MemoryRefShadow, so their tables were never created in the local SQLite bootstrap.
  • Bumps desktop version to 0.2.16.

Testing

  • pytest src/backend/tests/memory — 100 passed (includes new CE overlay contract tests).

Four fixes for long-term memory never landing in the desktop local build:

- The mem0 singleton captured the model config as of first use; saving the
  memory/embedding model afterwards only cleared the resolve cache, so writes
  kept failing 401 against the placeholder key. Model-config routes now also
  reset the memory runtime, and credential errors trigger a self-healing
  singleton rebuild (kept out of the Milvus circuit breaker).
- The CE audit stub narrowed its signature and raised TypeError on the real
  implementation's positional call style — after the DB commit, so successful
  L1 profile writes were reported as failures. The stub now accepts any call.
- The Milvus collection was created from the configured dimension (default
  1024) while the embedder returns its native width (e.g. 4096). Init now
  probes the real dimension with one /embeddings call and reconciles an
  existing collection: an empty one is dropped and rebuilt; a non-empty one
  (embedding-model switch) is re-embedded with the new model first and only
  then swapped, so data is never destroyed when the new model is unreachable.
- The CE models facade skipped the evolution models and MemoryRefShadow, so
  their tables never got created locally (23 'no such table' errors per run).

Also bump desktop version to 0.2.16 for the next release.
@Luhaozhu
Luhaozhu merged commit dd1317b into main Aug 5, 2026
5 checks passed
@Luhaozhu
Luhaozhu deleted the fix/local-memory-bootstrap branch August 5, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant