{"record":{"id":"987ba5cadf937675","repo":"mastra-ai/mastra","slug":"failed-to-initialize-task-manager-taskmanagerre","errorCode":null,"errorMessage":"Failed to initialize task manager: ${taskManagerResult.message}","messagePattern":"Failed to initialize task manager: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts","lineNumber":299,"sourceCode":"      // Pre-populate taskManager with the planned tasks\n      console.info('Pre-populating taskManager with planned tasks...');\n      const taskManagerContext = {\n        action: 'create' as const,\n        tasks: tasks.map(task => ({\n          id: task.id,\n          content: task.content,\n          status: 'pending' as const,\n          priority: task.priority,\n          dependencies: task.dependencies,\n          notes: task.notes,\n        })),\n      };\n\n      const taskManagerResult = await AgentBuilderDefaults.manageTaskList(taskManagerContext);\n      console.info(`Task manager initialized with ${taskManagerResult.tasks.length} tasks`);\n\n      if (!taskManagerResult.success) {\n        throw new Error(`Failed to initialize task manager: ${taskManagerResult.message}`);\n      }\n\n      const executionAgent = new AgentBuilder({\n        projectPath: currentProjectPath,\n        model,\n        tools: {\n          'task-manager': restrictedTaskManager,\n        },\n        instructions: `${workflowBuilderPrompts.executionAgent.instructions({\n          action,\n          workflowName,\n          tasksLength: tasks.length,\n          currentProjectPath,\n          discoveredWorkflows,\n          projectStructure,\n          research,\n          tasks,\n          resumeData,","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts#L281-L317","documentation":"workflow-builder calls AgentBuilderDefaults.manageTaskList to seed the task list before agent execution; if the returned result has success === false, this error is thrown embedding result.message. The task manager (backed by the agent's task tools / storage) could not be initialized, so the loop cannot track task completion and the run aborts.","triggerScenarios":"manageTaskList({ action: 'create'/seed ... }) returns { success: false, message } — e.g. the underlying agent call failed, the task tools are unavailable/misconfigured, storage for task state is unreachable, or the seeded task payload was rejected.","commonSituations":"Misconfigured task toolset or memory/storage in the AgentBuilder defaults, model/tool failures while creating tasks, or resource/permission errors writing task state in the target project.","solutions":["Read taskManagerResult.message in the thrown error for the underlying cause and fix that issue first","Verify the task-list tools are registered and storage/memory is correctly configured for the AgentBuilder run","Retry the workflow if the cause was a transient model/tool failure","If integrating custom defaults, ensure manageTaskList returns { success: true, tasks } on the happy path and only success:false for genuine failures"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"export async function assertTaskListReady(manageTaskList: typeof AgentBuilderDefaults.manageTaskList, ctx: unknown) {\n  const res = await manageTaskList(ctx);\n  if (!res.success) throw new Error(`Task manager not ready: ${res.message}`);\n  if (!Array.isArray(res.tasks)) throw new Error('Task manager returned no tasks array');\n}\n// probe before starting the full workflow","typeGuard":"export function taskManagerReady(r: { success: boolean; tasks?: unknown[] }): r is { success: true; tasks: unknown[] } {\n  return r.success === true && Array.isArray(r.tasks);\n}","tryCatchPattern":"try {\n  const res = await AgentBuilderDefaults.manageTaskList(ctx);\n  if (!res.success) throw new Error(`Task manager init failed: ${res.message}`);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to initialize task manager:')) {\n    // inspect res.message / storage & tool config, then retry\n  }\n  throw e;\n}","preventionTips":["Verify task tools and their backing storage are configured before workflow runs","Smoke-test manageTaskList in a preflight step to catch misconfig early","Retry transient model/tool failures with bounded backoff","Keep res.message informative so the wrapped error is actionable"],"tags":["task-manager","workflow-builder","agent"],"backgroundTag":"task-manager-init-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}