mastra-ai/mastra · error

Memory is not configured on this AgentController

Error message

Memory is not configured on this AgentController

What it means

cloneToCurrentResource copies a thread into the current session's resource, which requires persistent memory/storage. The library throws this when the AgentController has no memory store configured (this.#store is undefined or reports hasStorage() === false), because the thread lookup and clone cannot be performed without storage.

Source

Thrown at packages/core/src/agent-controller/session.ts:436

  /** Fetch a single thread by id, or null when it doesn't exist / no storage. */
  async getById({ threadId }: { threadId: string }): Promise<AgentControllerThread | null> {
    if (!this.#store) return null;
    return this.#store.getById({ threadId });
  }

  /** Clone a detected cross-resource project thread into this session's resource. */
  async cloneToCurrentResource({
    threadId,
    expectedResourceId,
    expectedProjectPath,
  }: {
    threadId: string;
    expectedResourceId: string;
    expectedProjectPath: string;
  }): Promise<AgentControllerThread> {
    if (!this.#store?.hasStorage()) {
      throw new Error('Memory is not configured on this AgentController');
    }
    const thread = await this.#store.getById({ threadId });
    if (
      !thread ||
      thread.resourceId !== expectedResourceId ||
      thread.metadata?.projectPath !== expectedProjectPath ||
      expectedResourceId === this.#getResourceId()
    ) {
      throw new Error(`Thread not found: ${threadId}`);
    }
    return this.#cloneThread({
      sourceThreadId: thread.id,
      resourceId: this.#getResourceId(),
      title: thread.title,
      metadata: thread.metadata,
    });
  }

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Configure memory with a storage backend on the Agent/AgentController (e.g. new Memory({ options: { storage } })).
  2. Hide or disable clone/switch-thread features when storage is unavailable — gate on the store's hasStorage().
  3. Pass the store explicitly to the AgentController if it was constructed without one.

Example fix

// before
const agent = new Agent({ name: 'x', model });
await agent.controller.cloneToCurrentResource({ threadId, expectedResourceId, expectedProjectPath }); // throws
// after
const agent = new Agent({ name: 'x', model, memory: new Memory({ options: { storage: new LibSQLStorage({ url }) } }) });
Defensive patterns

Strategy: validation

Validate before calling

const store = getControllerStore(controller);
if (!store || !store.hasStorage()) throw new Error('Enable memory/storage before cloning threads');

Try / catch

try {
  await session.cloneToCurrentResource({ threadId, expectedResourceId, expectedProjectPath });
} catch (e) {
  if (e instanceof Error && e.message === 'Memory is not configured on this AgentController') {
    // disable clone UI / prompt user to configure memory
  } else throw e;
}

Prevention

When it happens

Trigger: Calling cloneToCurrentResource (via promptForThreadSelection or a clonedThread flow) on an Agent constructed without memory/storage configured.

Common situations: Instantiating an Agent without a Memory instance or storage backend; running in a mode where storage was intentionally disabled but a clone/switch-thread UI action is still reachable.

Related errors


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