EmbeddingService default config is self-inconsistent: ollama default emits 768-dim vectors into a 1536-dim pgvector schema #1139

Open
opened 2026-08-09 20:41:13 +00:00 by Ghost · 0 comments

Found by shaggy during a boot smoke of a locally-built gateway image (2026-08-09); verified by fred against origin/next.

Defect

apps/gateway/src/memory/embedding.service.ts:

  • default provider is ollama (EMBEDDING_PROVIDER unset → ollama, header line 7)
  • OLLAMA_DEFAULT_DIMENSIONS = 768 (line 15) with nomic-embed-text
  • PGVECTOR_SCHEMA_DIMENSIONS = 1536 (line 22)

Live warning at boot with default config:

WARN [EmbeddingService] Embedding dimensions (768) differ from pgvector schema (1536).
If insights already contain 1536-dim vectors, similarity search will fail.

So the out-of-the-box federated configuration writes vectors that don't match its own schema. Note the trap: setting EMBEDDING_DIMENSIONS=1536 does not fix it — nomic-embed-text emits 768 dims regardless; it only silences the warning while the stored vectors stay the wrong width.

Actual options

  • Use the OpenAI backend (text-embedding-3-small, natively 1536), or
  • ALTER COLUMN the pgvector column to 768 + re-embed existing rows, or
  • make the schema dimension follow the configured backend (migration implications).

Whichever way, the defaults should be mutually consistent — a fresh install today boots into a warning that describes future data corruption of similarity search.

Refs: concrete mechanism behind the schema-compat risk flagged as UNVERIFIED in docs/scratchpads/mosaic-woltje-stack-proposal.md §5 (jarvis-brain).

Found by shaggy during a boot smoke of a locally-built gateway image (2026-08-09); verified by fred against `origin/next`. ## Defect `apps/gateway/src/memory/embedding.service.ts`: - default provider is **ollama** (`EMBEDDING_PROVIDER` unset → ollama, header line 7) - `OLLAMA_DEFAULT_DIMENSIONS = 768` (line 15) with `nomic-embed-text` - `PGVECTOR_SCHEMA_DIMENSIONS = 1536` (line 22) Live warning at boot with default config: ``` WARN [EmbeddingService] Embedding dimensions (768) differ from pgvector schema (1536). If insights already contain 1536-dim vectors, similarity search will fail. ``` So the out-of-the-box federated configuration writes vectors that don't match its own schema. Note the trap: setting `EMBEDDING_DIMENSIONS=1536` does **not** fix it — nomic-embed-text emits 768 dims regardless; it only silences the warning while the stored vectors stay the wrong width. ## Actual options - Use the OpenAI backend (`text-embedding-3-small`, natively 1536), or - `ALTER COLUMN` the pgvector column to 768 + re-embed existing rows, or - make the schema dimension follow the configured backend (migration implications). Whichever way, the *defaults* should be mutually consistent — a fresh install today boots into a warning that describes future data corruption of similarity search. Refs: concrete mechanism behind the schema-compat risk flagged as UNVERIFIED in `docs/scratchpads/mosaic-woltje-stack-proposal.md` §5 (jarvis-brain).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#1139