mastra-ai/mastra · error

Resource-scoped message listing is not implemented by this…

Error message

Resource-scoped message listing is not implemented by this storage adapter (${this.constructor.name}). Use an adapter that supports Observational Memory (pg, libsql, mongodb, convex) or disable observational memory.

What it means

The base MemoryDomain storage class provides a default listMessagesByResourceId that always throws, because resource-scoped message listing (used by Observational Memory and LongMemEval) must be implemented by the concrete adapter. Only pg, libsql, mongodb, and convex support it.

Solutions

  1. Switch to pg, libsql, mongodb, or convex storage
  2. Disable observational memory in your Mastra config if resource-scoped listing isn't needed
  3. Implement listMessagesByResourceId in your custom adapter
  4. Query messages per-thread instead of per-resource

Example fix

// before
new Mastra({ storage: new InMemoryStore(), /* observational memory enabled */ });
// after
new Mastra({ storage: new LibSQLStore({ url: 'file:./mastra.db' }), /* observational memory works */ });
Defensive patterns

Strategy: fallback

Validate before calling

function supportsResourceMessages(storage: unknown): boolean {
  return typeof (storage as any)?.listMessagesByResourceId === 'function' &&
    (storage as any).listMessagesByResourceId !== (MastraStorage.prototype as any).listMessagesByResourceId;
}

Type guard

function canListByResource(s: unknown): s is { listMessagesByResourceId(a: StorageListMessagesByResourceIdInput): Promise<StorageListMessagesOutput> } {
  return supportsResourceMessages(s);
}

Try / catch

try {
  return await storage.listMessagesByResourceId({ resourceId });
} catch (e) {
  if (e instanceof Error && e.message.includes('Resource-scoped message listing is not implemented')) {
    // fallback: aggregate messages across the resource's threads
    return listMessagesAcrossThreads(resourceId);
  }
  throw e;
}

Prevention

When it happens

Trigger: Using Observational Memory or resource-scoped message queries with a storage adapter that does not override listMessagesByResourceId, e.g. an in-memory store or a minimal custom adapter.

Common situations: Enabling observational memory without switching from the default/in-memory storage; swapping storage backends in dev; writing a custom adapter and missing this optional method.

Related errors


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

Appendix: source

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

      id,
      ...(title !== undefined ? { title } : {}),
      ...(metadata !== undefined ? { metadata } : {}),
    });
  }

  abstract deleteThread({ threadId }: { threadId: string }): Promise<void>;

  abstract listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;

  /**
   * List messages by resource ID only (across all threads).
   * Used by Observational Memory and LongMemEval for resource-scoped queries.
   *
   * @param args - Resource ID and pagination/filtering options
   * @returns Paginated list of messages for the resource
   */
  async listMessagesByResourceId(_args: StorageListMessagesByResourceIdInput): Promise<StorageListMessagesOutput> {
    throw new Error(
      `Resource-scoped message listing is not implemented by this storage adapter (${this.constructor.name}). ` +
        `Use an adapter that supports Observational Memory (pg, libsql, mongodb, convex) or disable observational memory.`,
    );
  }

  abstract listMessagesById({ messageIds }: { messageIds: string[] }): Promise<{ messages: MastraDBMessage[] }>;

  abstract saveMessages(args: { messages: MastraDBMessage[] }): Promise<{ messages: MastraDBMessage[] }>;

  abstract updateMessages(args: {
    messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
      id: string;
      content?: { metadata?: MastraMessageContentV2['metadata']; content?: MastraMessageContentV2['content'] };
    })[];
  }): Promise<MastraDBMessage[]>;

  async deleteMessages(_messageIds: string[]): Promise<void> {
    throw new Error(

View on GitHub (pinned to 75dd419e61)