mastra-ai/mastra · error

Tried to create observation embedding index but no vector db

Error message

Tried to create observation embedding index but no vector db is attached to this Memory instance.

What it means

createObservationEmbeddingIndex creates a vector index for observational memory embeddings; it requires a vector store attached to the Memory instance. If this.vector is undefined it throws before calling vector.createIndex, since there is no target to create the index in.

Source

Thrown at packages/memory/src/index.ts:2194

        "workingMemory.useStateSignals is not supported with workingMemory.version: 'vnext'. Use stable template working memory or disable useStateSignals.",
      );
    }
  }

  private getObservationEmbeddingIndexName(dimensions?: number): string {
    const defaultDimensions = 384;
    const usedDimensions = dimensions ?? defaultDimensions;
    const separator = this.vector?.indexSeparator ?? '_';
    return `${this.observationIndexPrefix}${separator}${usedDimensions}`;
  }

  private async createObservationEmbeddingIndex(dimensions?: number): Promise<{ indexName: string }> {
    const defaultDimensions = 384;
    const usedDimensions = dimensions ?? defaultDimensions;
    const indexName = this.getObservationEmbeddingIndexName(dimensions);

    if (typeof this.vector === `undefined`) {
      throw new Error(
        `Tried to create observation embedding index but no vector db is attached to this Memory instance.`,
      );
    }

    await this.vector.createIndex({
      indexName,
      dimension: usedDimensions,
    } as any);

    return { indexName };
  }

  /**
   * Search observation groups across threads by semantic similarity.
   * Requires a vector store and embedder to be configured.
   */
  public async searchMessages({
    query,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Attach a vector store to Memory: new Memory({ storage, embedder, vector: new LibSQLVector(...) }) or equivalent (PgVector, etc.).
  2. Disable the observational memory features that require embeddings if a vector store is not desired.
  3. Confirm your config builder passes the vector option through to the Memory constructor.

Example fix

// before
const memory = new Memory({ storage, options: { observationalMemory: { enabled: true } } });
// after
import { LibSQLVector } from '@mastra/libsql';
const memory = new Memory({ storage, vector: new LibSQLVector({ connectionUrl: 'file:./vectors.db' }), options: { observationalMemory: { enabled: true } } });
Defensive patterns

Strategy: validation

Validate before calling

if (memoryConfig.observationalMemory?.enabled && !memoryConfig.vector) {
  throw new Error('Observational memory embedding index requires a vector store on Memory');
}

Type guard

function hasVector(m: Memory): boolean {
  return typeof (m as unknown as { vector?: unknown }).vector !== 'undefined';
}

Try / catch

try {
  await memory.getObservationalMemory();
} catch (e) {
  if (e instanceof Error && e.message.includes('no vector db is attached')) {
    console.error('Attach a vector store (e.g. LibSQLVector) to the Memory instance.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Enabling observationalMemory with embedding-dependent features (e.g. observation embeddings / experimental subconscious) on a Memory configured without a vector store.

Common situations: Adding observationalMemory to an existing Memory({ storage, embedder }) setup that never needed a vector DB; forgetting that OM observation embeddings require vector storage even if chat-level semantic recall is off.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/f04a3e5802fbab0a. Report an issue: GitHub.