ruvnet/ruflo · error

Vector dimension mismatch: expected ${this.config.dimensions

Error message

Vector dimension mismatch: expected ${this.config.dimensions}, got ${vector.length}

What it means

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.

Source

Thrown at v3/@claude-flow/plugins/src/integrations/agentic-flow.ts:575

   * Shutdown AgentDB.
   */
  async shutdown(): Promise<void> {
    if (!this.initialized) return;

    this.vectors.clear();
    this.initialized = false;
  }

  /**
   * Store a vector.
   */
  async store(id: string, vector: Float32Array, metadata?: Record<string, unknown>): Promise<void> {
    if (!this.initialized) {
      throw new Error('AgentDB not initialized');
    }

    if (vector.length !== this.config.dimensions) {
      throw new Error(`Vector dimension mismatch: expected ${this.config.dimensions}, got ${vector.length}`);
    }

    const entry: VectorEntry = {
      id,
      vector,
      metadata,
      timestamp: new Date(),
    };

    this.vectors.set(id, entry);

    this.emit(AGENTIC_FLOW_EVENTS.MEMORY_STORED, {
      id,
      timestamp: new Date(),
    });
  }

  /**

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Set config.dimensions to your embedding model's exact output size at initialize() and keep it fixed for the store's lifetime
  2. If the model changed, re-initialize a fresh store and re-embed all vectors — mixed dimensions cannot coexist
  3. Assert vector.length === dimensions at the call site before storing to fail with your own context-rich error

Example fix

// before
await db.initialize({ dimensions: 1536 });
await db.store('v1', embed3072(text)); // Error: mismatch: expected 1536, got 3072

// after
await db.initialize({ dimensions: 3072 });
await db.store('v1', embed3072(text));
// pre-check helper:
function assertDims(v: Float32Array, dims: number): void {
  if (v.length !== dims) throw new RangeError(`embedding is ${v.length}d, store expects ${dims}d`);
}
Defensive patterns

Strategy: validation

Validate before calling

const DIMS = 1536; // must match your embedding model output
await db.initialize({ dimensions: DIMS });
function assertDims(v: Float32Array): void {
  if (v.length !== DIMS) {
    throw new RangeError(`embedding is ${v.length}d; store configured for ${DIMS}d`);
  }
}
await (assertDims(vec), db.store('v1', vec));

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/5b101706a93f3e66. Report an issue: GitHub.