mastra-ai/mastra · error

Observational memory is not implemented by this storage adap

Error message

Observational memory is not implemented by this storage adapter (${this.constructor.name}).

What it means

Thrown by the base MemoryStorageDomain's getObservationalMemory default implementation. Unlike resource support, observational memory is an optional capability, and adapters that don't support it throw this explicit error rather than returning null, so callers know the feature is unavailable rather than merely empty.

Source

Thrown at packages/core/src/storage/domains/memory/base.ts:244

        orderBy?.direction && orderBy.direction in THREAD_THREAD_SORT_DIRECTION_SET
          ? orderBy.direction
          : defaultDirection,
    };
  }

  // ============================================
  // Observational Memory Methods
  // ============================================

  /**
   * Get the current observational memory record for a thread/resource.
   * Returns the most recent active record.
   */
  async getObservationalMemory(
    _threadId: string | null,
    _resourceId: string,
  ): Promise<ObservationalMemoryRecord | null> {
    throw new Error(`Observational memory is not implemented by this storage adapter (${this.constructor.name}).`);
  }

  /**
   * Get observational memory history (previous generations).
   * Returns records in reverse chronological order (newest first).
   */
  async getObservationalMemoryHistory(
    _threadId: string | null,
    _resourceId: string,
    _limit?: number,
    _options?: ObservationalMemoryHistoryOptions,
  ): Promise<ObservationalMemoryRecord[]> {
    throw new Error(`Observational memory is not implemented by this storage adapter (${this.constructor.name}).`);
  }

  /**
   * Create a new observational memory record.
   * Called when starting observations for a new thread/resource.

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Switch to a storage adapter that implements observational memory (e.g. current PostgreSQL, MongoDB, or InMemory adapter).
  2. Upgrade your adapter package to the latest version supporting observational memory.
  3. Disable observational memory in the Memory configuration if your adapter can't support it.
  4. Implement the observational-memory method family in your custom adapter.

Example fix

// before
new Mastra({ storage: new LegacyCustomStore() }); // memory: { observationalMemory: { enabled: true } }
// after
new Mastra({ storage: new PostgresStore({ connectionString: url }) }); // implements observational memory
Defensive patterns

Strategy: fallback

Validate before calling

// capability probe before relying on observational memory
async function hasObservationalMemory(storage: MastraStorage) {
  try { await storage.getObservationalMemory(null, '__probe__'); return true; }
  catch (e) { return !String((e as Error).message).includes('Observational memory is not implemented'); }
}

Type guard

function supportsObservationalMemory(s: unknown): boolean {
  const proto = Object.getPrototypeOf(s);
  return Object.getPrototypeOf(proto) && 'initializeObservationalMemory' in proto &&
    (s as any).constructor.name !== 'MastraStorage';
}

Try / catch

let record: ObservationalMemoryRecord | null = null;
try {
  record = await storage.getObservationalMemory(threadId, resourceId);
} catch (e) {
  if (String((e as Error).message).includes('Observational memory is not implemented')) {
    record = null; // feature unsupported; degrade gracefully
  } else throw e;
}

Prevention

When it happens

Trigger: Calling getObservationalMemory(threadId, resourceId) — directly or via Memory with observational memory enabled — on an adapter that has no observational-memory overrides.

Common situations: Enabling observational memory in Memory config while using a storage adapter (e.g. older LibSQL, Upstash, or custom adapter) that hasn't implemented it; upgrading core but not the adapter package.

Related errors


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