Skip to content

fix(memory): rebuild vec tables on embedder dimension change#138

Merged
rajkumarsakthivel merged 2 commits into
elara-labs:mainfrom
glitch-ux:fix/memory-vec-dim-rebuild
Jul 13, 2026
Merged

fix(memory): rebuild vec tables on embedder dimension change#138
rajkumarsakthivel merged 2 commits into
elara-labs:mainfrom
glitch-ux:fix/memory-vec-dim-rebuild

Conversation

@glitch-ux

Copy link
Copy Markdown
Contributor

Closes #137.

Problem

decisions_vec / turn_summaries_vec are created at a hardcoded float[384] (_VEC_DIM) and never rebuilt when the project's embedder has a different dimension. _write_vec_row swallows the resulting dimension-mismatch OperationalError at debug, so every semantic-memory write is silently dropped and session_recall returns nothing, permanently — no error surfaced. This hits the common zero-dependency path: without the [local] extra, cce falls back to Ollama, whose default nomic-embed-text is 768-dim.

The comment at memory/db.py:30 already pointed at a _ensure_vec_dim rebuild — but it was never implemented (grep matched only the comment). The code index solves the same problem via VectorStore._ensure_vec_table; this brings the memory subsystem to parity.

Fix

  • Add _ensure_vec_dim(conn, dim) (+ _declared_vec_dim): when the active embedder's dimension differs from the vec tables', drop and recreate both *_vec tables at the new dimension. The decisions / turn_summaries source rows are untouchedbackfill_vec_tables re-embeds them.
  • Call it from the record_*_vec writers (self-heals on the next write) and reconcile up front in backfill_vec_tables (runs at cce serve startup, so an already-populated index is repaired too — the NOT EXISTS filter alone would miss that case).

Both vec tables always share the embedder's dimension, so they're rebuilt together. No change to the source schema, migrations, or the 384-dim default path.

Testing

…abs#137)

The decisions_vec / turn_summaries_vec tables were created at a hardcoded
float[384] and never rebuilt, so any non-384-dim embedder (e.g. Ollama's
default nomic-embed-text at 768) made every vec write a silently-swallowed
dimension mismatch and killed semantic memory recall permanently.

Implement the previously-referenced-but-missing _ensure_vec_dim (mirroring
VectorStore._ensure_vec_table): drop + recreate both vec tables at the active
embedder's dimension, leaving the source rows for backfill to re-embed. Hook
it into the record_*_vec writers and reconcile up front in backfill_vec_tables
so an already-populated index is repaired at cce serve startup too.

Adds tests/memory/test_vec_dim.py covering the rebuild, the matching-dim
no-op, and backfill after a dimension swap.
@rajkumarsakthivel rajkumarsakthivel merged commit da47cac into elara-labs:main Jul 13, 2026
19 checks passed
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.

Memory vec tables hardcode dim=384 and are never rebuilt on embedder change → semantic recall silently dies

2 participants