mastra-ai/mastra · error

Thread cloning is not implemented by this storage adapter ($

Error message

Thread cloning is not implemented by this storage adapter (${this.constructor.name}). The cloneThread method needs to be implemented in the storage adapter.

What it means

cloneThread is an optional adapter capability; the base class default throws because thread cloning (copying a thread plus its messages with clone metadata) must be implemented by the concrete adapter. The active adapter has not implemented it.

Source

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

   * List threads with optional filtering by resourceId and metadata.
   *
   * @param args - Filter, pagination, and ordering options
   * @param args.filter - Optional filters for resourceId and/or metadata
   * @param args.filter.resourceId - Optional resource ID to filter by
   * @param args.filter.metadata - Optional metadata key-value pairs to filter by (AND logic)
   * @returns Paginated list of threads matching the filters
   */
  abstract listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput>;

  /**
   * Clone a thread and its messages to create a new independent thread.
   * The cloned thread will have clone metadata stored in its metadata field.
   *
   * @param args - Clone configuration options
   * @returns The newly created thread and the cloned messages
   */
  async cloneThread(_args: StorageCloneThreadInput): Promise<StorageCloneThreadOutput> {
    throw new Error(
      `Thread cloning is not implemented by this storage adapter (${this.constructor.name}). ` +
        `The cloneThread method needs to be implemented in the storage adapter.`,
    );
  }

  async getResourceById(_: { resourceId: string }): Promise<StorageResourceType | null> {
    throw new Error(
      `Resource working memory is not implemented by this storage adapter (${this.constructor.name}). ` +
        `This is likely a bug - all Mastra storage adapters should implement resource support. ` +
        `Please report this issue at https://github.com/mastra-ai/mastra/issues`,
    );
  }

  async saveResource(_: { resource: StorageResourceType }): Promise<StorageResourceType> {
    throw new Error(
      `Resource working memory is not implemented by this storage adapter (${this.constructor.name}). ` +
        `This is likely a bug - all Mastra storage adapters should implement resource support. ` +
        `Please report this issue at https://github.com/mastra-ai/mastra/issues`,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Use an adapter that implements cloneThread
  2. Implement cloneThread in your adapter (copy thread row with clone metadata plus all messages)
  3. Fork at the application level by manually creating a new thread and re-inserting messages

Example fix

// before
await storage.cloneThread({ threadId, newResourceId }); // throws
// after
// app-level fork, or implement in the adapter:
async cloneThread(args) { /* insert cloned thread + messages */ }
Defensive patterns

Strategy: fallback

Validate before calling

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

Type guard

function canCloneThread(s: unknown): s is { cloneThread(a: StorageCloneThreadInput): Promise<StorageCloneThreadOutput> } {
  return supportsCloneThread(s);
}

Try / catch

try {
  return await storage.cloneThread(args);
} catch (e) {
  if (e instanceof Error && e.message.includes('Thread cloning is not implemented')) {
    return manualCloneThread(args); // app-level fork: new thread + copied messages
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling cloneThread(args) (e.g. from memory/fork-thread flows) against an adapter that doesn't override cloneThread, such as a minimal custom store or an in-memory store.

Common situations: Forking a conversation thread in dev with a stub storage backend; custom adapters missing newer optional methods; third-party adapters lagging the core API.

Related errors


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