ruvnet/ruflo · error · Error

vector must be a non-empty numeric array

Error message

vector must be a non-empty numeric array

What it means

Thrown by the agenticow_query MCP tool handler when the `vector` argument is not a non-empty array. The query performs a k-nearest-neighbour search against an .rvf memory file, so a valid query vector is the one mandatory input (path and vector are both required). The guard runs before the lineage store is opened.

Source

Thrown at v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts:172

    tags: ['agenticow', 'memory', 'cow', 'query', 'read', 'search'],
    inputSchema: {
      type: 'object',
      properties: {
        path: { type: 'string', description: 'Path to .rvf memory file' },
        vector: { type: 'array', items: { type: 'number' }, description: 'Query embedding vector' },
        k: { type: 'integer', description: 'Number of nearest neighbors to return', default: 10 },
        efSearch: { type: 'integer', description: 'HNSW efSearch per lineage store (higher = better recall, slower)' },
      },
      required: ['path', 'vector'],
    },
    handler: async (input) => {
      const api = await loadAgenticow();
      if (!api) return degradedResult('agenticow-not-found');

      const path = resolveMemoryPath(String(input.path));
      const vector = input.vector as number[];
      if (!Array.isArray(vector) || vector.length === 0) {
        throw new Error('vector must be a non-empty numeric array');
      }
      const k = typeof input.k === 'number' ? input.k : 10;
      const opts: Record<string, unknown> = {};
      if (typeof input.efSearch === 'number') opts.efSearch = input.efSearch;
      const mem = await openWithLineage(api, path);
      try {
        const hits = await mem.query(vector, k, opts);
        return { success: true, path, k, hits };
      } finally {
        await mem.close?.();
      }
    },
  },
  {
    name: 'agenticow_diff',
    description: 'agenticow — show what a branch changed relative to its lineage: {added, overridden, deleted} vector-id lists. Use when you are about to promote and want to preview the exact merge, or when auditing what a branch actually wrote. Diffing by re-querying is wrong because deletions (tombstones) are invisible to a read — diff() surfaces them explicitly. Requires the branch was opened with edit tracking (default on).',
    category: 'memory',
    tags: ['agenticow', 'memory', 'cow', 'diff'],

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Pass vector as a non-empty numeric array whose length equals the store dimension.
  2. Wrap embedding generation in a null/empty check before querying.
  3. Convert Float32Array/Float64Array via Array.from(...) — they fail Array.isArray.
  4. Verify the embedding pipeline returned a dense vector, not a sparse object representation.

Example fix

// before
agenticow_query({ path, vector: embedding })
// after
const v = Array.isArray(embedding) ? embedding : Array.from(embedding)
if (!v || v.length === 0) throw new Error('empty embedding')
agenticow_query({ path, vector: v })
Defensive patterns

Strategy: validation

Validate before calling

function validateQueryVector(vector) {
  const v = Array.isArray(vector) ? vector : Array.from(vector ?? []);
  if (!v || v.length === 0) throw new Error('query vector must be a non-empty array');
  if (!v.every((n) => typeof n === 'number' && Number.isFinite(n))) throw new Error('query vector must be all finite numbers');
  return v;
}

Type guard

function isQueryVector(v: unknown): v is number[] {
  return Array.isArray(v) && v.length > 0 && v.every((n) => typeof n === 'number' && Number.isFinite(n));
}

Prevention

When it happens

Trigger: Calling agenticow_query with vector omitted, null, a non-array, or an empty array []. Even though the JSON schema requires vector, direct handler callers bypass schema validation.

Common situations: Passing a single number instead of an array; an embedding model returning null on failure; a serialised vector string that was never parsed; a typed array that fails Array.isArray.

Related errors


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/5b4177942feb84b1. Report an issue: GitHub.