{"record":{"id":"b5194a1f49bc190e","repo":"mastra-ai/mastra","slug":"mastra-is-not-registered-with-this-manager","errorCode":null,"errorMessage":"Mastra is not registered with this manager","messagePattern":"Mastra is not registered with this manager","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/core/src/background-tasks/manager.ts","lineNumber":417,"sourceCode":"      return;\n    }\n  }\n\n  /**\n   * Resume a suspended task. The tool executor must be re-registered via\n   * `registerTaskContext(taskId, ...)` before calling this if the original\n   * registration is gone (e.g. process restart) — the manager doesn't\n   * rehydrate executor closures from storage.\n   *\n   * `resumeData` is forwarded to the tool's `execute` options on the\n   * resumed run.\n   */\n  async resume(taskId: string, resumeData?: unknown): Promise<BackgroundTask> {\n    if (this.shuttingDown) {\n      throw new Error('BackgroundTaskManager is shutting down, cannot resume tasks');\n    }\n    if (!this.#mastra) {\n      throw new Error('Mastra is not registered with this manager');\n    }\n\n    if (this.initPromise) await this.initPromise;\n\n    const storage = await this.getStorage();\n    const task = await storage.getTask(taskId);\n    if (!task) {\n      throw new Error(`Task not found: ${taskId}`);\n    }\n    if (task.status !== 'suspended') {\n      throw new Error(`Cannot resume task in status '${task.status}' (expected 'suspended')`);\n    }\n\n    const canRun = await this.checkConcurrency(task.agentId);\n    if (!canRun) {\n      // Resume sits outside the queue/fallback-sync paths — there's no\n      // synchronous caller to fall back to, and silently leaving the task\n      // suspended hides the failure from the caller. Throw and let the","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/background-tasks/manager.ts#L399-L435","documentation":"resume() needs the Mastra instance to look up the suspended workflow run and re-drive it. If no Mastra instance was registered on the BackgroundTaskManager (#mastra is undefined), resuming is impossible and the manager throws. This is a wiring/configuration error.","triggerScenarios":"Creating BackgroundTaskManager without registering a Mastra instance, then calling resume(); manager constructed manually (e.g. in a script/test) without the mastra reference; a manager obtained via makeLocalManager path lacking registration.","commonSituations":"Standalone scripts resuming tasks with a hand-built manager; tests constructing the manager without Mastra; refactor where the Mastra registration call was dropped.","solutions":["Register Mastra on the manager at construction: `new BackgroundTaskManager(mastra)` or the registration API used in your setup.","In scripts/tests, construct Mastra (with storage) and pass it to the manager before resuming.","Use the manager instance exposed by the Mastra instance (mastra background task manager accessor) instead of building a new one.","Audit manager construction sites for the missing mastra argument."],"exampleFix":"// before\nconst manager = new BackgroundTaskManager();\nawait manager.resume(taskId, data); // Mastra is not registered\n// after\nconst mastra = getMastra();\nconst manager = new BackgroundTaskManager(mastra);\nawait manager.resume(taskId, data);","handlingStrategy":"validation","validationCode":"const manager = mastra.getBackgroundTaskManager?.() ?? new BackgroundTaskManager(mastra);\nif (!managerHasMastra(manager)) throw new Error('Register Mastra before resuming tasks');","typeGuard":"function managerHasMastra(m: BackgroundTaskManager): boolean {\n  return typeof (m as any).#mastra !== 'undefined' || (m as any)['#mastra'] instanceof Mastra;\n} // in practice: construct with mastra so it is always set","tryCatchPattern":"try {\n  await manager.resume(taskId, data);\n} catch (e) {\n  if ((e as Error).message === 'Mastra is not registered with this manager') {\n    throw new Error('Bug: construct BackgroundTaskManager with the Mastra instance');\n  }\n  throw e;\n}","preventionTips":["Always construct BackgroundTaskManager with the Mastra instance.","Prefer the manager accessor on the Mastra instance over manual construction.","Keep registration in one shared bootstrap module.","Add a unit test asserting resume works with the app's real manager construction."],"tags":["background-tasks","configuration","mastra"],"backgroundTag":"mastra-not-registered","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}