mastra-ai/mastra · error
Failed to initialize task manager: ${taskManagerResult.messa
Error message
Failed to initialize task manager: ${taskManagerResult.message} What it means
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.
Source
Thrown at packages/agent-builder/src/workflows/workflow-builder/workflow-builder.ts:299
// Pre-populate taskManager with the planned tasks
console.info('Pre-populating taskManager with planned tasks...');
const taskManagerContext = {
action: 'create' as const,
tasks: tasks.map(task => ({
id: task.id,
content: task.content,
status: 'pending' as const,
priority: task.priority,
dependencies: task.dependencies,
notes: task.notes,
})),
};
const taskManagerResult = await AgentBuilderDefaults.manageTaskList(taskManagerContext);
console.info(`Task manager initialized with ${taskManagerResult.tasks.length} tasks`);
if (!taskManagerResult.success) {
throw new Error(`Failed to initialize task manager: ${taskManagerResult.message}`);
}
const executionAgent = new AgentBuilder({
projectPath: currentProjectPath,
model,
tools: {
'task-manager': restrictedTaskManager,
},
instructions: `${workflowBuilderPrompts.executionAgent.instructions({
action,
workflowName,
tasksLength: tasks.length,
currentProjectPath,
discoveredWorkflows,
projectStructure,
research,
tasks,
resumeData,View on GitHub (pinned to 75dd419e61)
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
Defensive patterns
Strategy: try-catch
Validate before calling
export async function assertTaskListReady(manageTaskList: typeof AgentBuilderDefaults.manageTaskList, ctx: unknown) {
const res = await manageTaskList(ctx);
if (!res.success) throw new Error(`Task manager not ready: ${res.message}`);
if (!Array.isArray(res.tasks)) throw new Error('Task manager returned no tasks array');
}
// probe before starting the full workflow Type guard
export function taskManagerReady(r: { success: boolean; tasks?: unknown[] }): r is { success: true; tasks: unknown[] } {
return r.success === true && Array.isArray(r.tasks);
} Try / catch
try {
const res = await AgentBuilderDefaults.manageTaskList(ctx);
if (!res.success) throw new Error(`Task manager init failed: ${res.message}`);
} catch (e) {
if (e instanceof Error && e.message.startsWith('Failed to initialize task manager:')) {
// inspect res.message / storage & tool config, then retry
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No result received from agent execution on iteration ${itera
- No result received from agent execution
- AGENT_GENERATE_LEGACY_STRUCTURED_OUTPUT_NOT_SUPPORTED
- AGENT_GENERATE_V2_MODEL_NOT_SUPPORTED
- AGENT_STREAM_V2_MODEL_NOT_SUPPORTED
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/987ba5cadf937675.
Report an issue: GitHub.