{"record":{"id":"5b101706a93f3e66","repo":"ruvnet/ruflo","slug":"vector-dimension-mismatch-expected-this-config","errorCode":null,"errorMessage":"Vector dimension mismatch: expected ${this.config.dimensions}, got ${vector.length}","messagePattern":"Vector dimension mismatch: expected (.+?), got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugins/src/integrations/agentic-flow.ts","lineNumber":575,"sourceCode":"   * Shutdown AgentDB.\n   */\n  async shutdown(): Promise<void> {\n    if (!this.initialized) return;\n\n    this.vectors.clear();\n    this.initialized = false;\n  }\n\n  /**\n   * Store a vector.\n   */\n  async store(id: string, vector: Float32Array, metadata?: Record<string, unknown>): Promise<void> {\n    if (!this.initialized) {\n      throw new Error('AgentDB not initialized');\n    }\n\n    if (vector.length !== this.config.dimensions) {\n      throw new Error(`Vector dimension mismatch: expected ${this.config.dimensions}, got ${vector.length}`);\n    }\n\n    const entry: VectorEntry = {\n      id,\n      vector,\n      metadata,\n      timestamp: new Date(),\n    };\n\n    this.vectors.set(id, entry);\n\n    this.emit(AGENTIC_FLOW_EVENTS.MEMORY_STORED, {\n      id,\n      timestamp: new Date(),\n    });\n  }\n\n  /**","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugins/src/integrations/agentic-flow.ts#L557-L593","documentation":"store() enforces vector.length === config.dimensions exactly — the dimension count the store was initialized with. Any other length is rejected outright; there is no padding, truncation, or coercion. Note the check runs on the plain .length of the passed Float32Array, so off-by-one arrays and wrong-model embeddings are caught here.","triggerScenarios":"Mixing embedding models with different output sizes (1536 vs 3072 dims) against one store; initializing the store with different dimensions than the embedding pipeline emits; passing a truncated or off-by-one Float32Array; changing dimensions config without recreating the store contents.","commonSituations":"Switching OpenAI embedding models (or moving to a local model) mid-project; copy-pasting example config with different dimensions; multiple embedders (query vs document) with inconsistent sizes.","solutions":["Set config.dimensions to your embedding model's exact output size at initialize() and keep it fixed for the store's lifetime","If the model changed, re-initialize a fresh store and re-embed all vectors — mixed dimensions cannot coexist","Assert vector.length === dimensions at the call site before storing to fail with your own context-rich error"],"exampleFix":"// before\nawait db.initialize({ dimensions: 1536 });\nawait db.store('v1', embed3072(text)); // Error: mismatch: expected 1536, got 3072\n\n// after\nawait db.initialize({ dimensions: 3072 });\nawait db.store('v1', embed3072(text));\n// pre-check helper:\nfunction assertDims(v: Float32Array, dims: number): void {\n  if (v.length !== dims) throw new RangeError(`embedding is ${v.length}d, store expects ${dims}d`);\n}","handlingStrategy":"validation","validationCode":"const DIMS = 1536; // must match your embedding model output\nawait db.initialize({ dimensions: DIMS });\nfunction assertDims(v: Float32Array): void {\n  if (v.length !== DIMS) {\n    throw new RangeError(`embedding is ${v.length}d; store configured for ${DIMS}d`);\n  }\n}\nawait (assertDims(vec), db.store('v1', vec));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin config.dimensions to the embedding model and never mix models in one store","Re-embed everything when switching models; do not partially migrate","Use a single embed() helper for both store and query vectors"],"tags":["agentdb","vectors","embeddings","validation"],"backgroundTag":"vector-dimension-mismatch","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}