mem0ai/mem0 · error · Error
${label} dimension mismatch. Expected ${this.dimension}, got
Error message
${label} dimension mismatch. Expected ${this.dimension}, got ${vector.length} What it means
assertVectorDimension() throws when a vector passed for insert/update does not match this.dimension, the configured embedding dimension. Databricks Vector Search indexes have a fixed embedding column width; a mismatched vector would be rejected server-side, so the provider validates client-side first with a clearer message.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/databricks.ts:1456
return {};
}
private extractSessionValues(payload: Record<string, any>): {
user_id: any;
agent_id: any;
run_id: any;
} {
return {
user_id: payload.user_id,
agent_id: payload.agent_id,
run_id: payload.run_id,
};
}
private assertVectorDimension(vector: number[], label: string): void {
if (vector.length !== this.dimension) {
throw new Error(
`${label} dimension mismatch. Expected ${this.dimension}, got ${vector.length}`,
);
}
for (const value of vector) {
if (!Number.isFinite(value)) {
throw new Error(
`${label} values must be finite numbers for Databricks vector search.`,
);
}
}
}
private matchFieldCondition(
vector: DatabricksVector,
key: string,
value: any,
): boolean {
const fieldValue = key === "memory_id" ? vector.id : vector.payload[key];View on GitHub (pinned to 001c235229)
Solutions
- Make the embedding model used by Memory match the dimension the Databricks index was created with, and pass that same dimension in the store config.
- If you intentionally changed embedding models, create a new Databricks Vector Search index with the new dimension and point config at it.
- Log vector.length at the call site to identify which embedder produced the mismatched vector.
- Verify config.dimension matches the index's embedding column length in Databricks.
Example fix
// before
const store = new DatabricksDB({ ...opts, dimension: 1536 });
const memory = new Memory({ vectorStore: store, embedder: new OllamaEmbedder() }); // 768-dim
// after
const memory = new Memory({
vectorStore: new DatabricksDB({ ...opts, dimension: 768 }), // matches embedder
embedder: new OllamaEmbedder(),
}); Defensive patterns
Strategy: validation
Validate before calling
const dim = await embedder.embed('probe');
if (dim.embedding.length !== storeConfig.dimension) {
throw new Error(`Embedder emits ${dim.embedding.length}-d vectors but store configured for ${storeConfig.dimension}`);
} Type guard
const isDimensionOk = (v: number[], expected: number) => Array.isArray(v) && v.length === expected;
Try / catch
try {
await store.insert(vectors, ids, payloads);
} catch (e) {
if (e instanceof Error && /dimension mismatch/i.test(e.message)) {
// align embedder and index dimension, recreate index if the model changed
}
throw e;
} Prevention
- Derive config.dimension from a probe embedding at startup instead of hardcoding it.
- Use a single embedding model across memory add/search/store paths.
- Recreate the Databricks index when switching embedding models.
When it happens
Trigger: Calling insert() or update() with vectors produced by a different embedding model than the one whose dimension the store was configured with (e.g. 1536-dim OpenAI vectors sent to a 768-dim index), or mixing embedding providers between memory add and store config.
Common situations: Switching the embedding provider (e.g. from OpenAI text-embedding-3-small to a local 384-dim model) without recreating the Databricks index; sharing one store across two memory instances with different embedders; a custom embedding function returning padded/truncated vectors.
Related errors
- ${label} values must be finite numbers for Databricks vector
- Unknown embedder provider: ${providerId}
- Langchain embedder provider requires an initialized Langchai
- Provided Langchain 'instance' in the 'model' field does not
- Invalid memory action: ${memoryAction}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/c0da84ff33faa537.
Report an issue: GitHub.