mastra-ai/mastra · error
create-workflow failed: the workflow-builder sub-agent never
Error message
create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}
Sub-agent summary:
${summary} What it means
If the workflow-builder sub-agent finished its turn without ever invoking save-workflow, create-workflow throws this error stating no workflow was persisted. It guards against the sub-agent hallucinating success while nothing was saved.
Source
Thrown at mastracode/sdk/src/tools/workflows/create-workflow.ts:114
// If save-workflow errored, surface that error explicitly — do NOT return
// the sub-agent's summary as if things were fine.
const saveErrors = toolErrors.filter(e => e.toolName === 'save-workflow');
if (saveErrors.length > 0 && !saveSucceeded) {
throw new Error(
`create-workflow failed: save-workflow threw ${saveErrors.length} error(s):\n- ${saveErrors
.map(e => e.error)
.join('\n- ')}\n\nSub-agent summary (unreliable, save did not succeed):\n${summary}`,
);
}
// If save-workflow was never called, the sub-agent gave up (or hallucinated
// success). Fail loudly so the caller doesn't think a workflow exists.
if (!saveAttempted) {
const otherErrors = toolErrors.length
? `\n\nOther sub-agent tool errors:\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\n- ')}`
: '';
throw new Error(
`create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\n\nSub-agent summary:\n${summary}`,
);
}
// Save was attempted but never returned ok (no tool-result with { ok: true, id }).
if (!saveSucceeded) {
const otherErrors = toolErrors.length
? `\n\nSub-agent tool errors:\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\n- ')}`
: '';
throw new Error(
`create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\n\nSub-agent summary:\n${summary}`,
);
}
return { summary, workflowId };
},
});
View on GitHub (pinned to 75dd419e61)
Solutions
- Re-run the request; instruct the agent to explicitly call save-workflow before finishing.
- Check toolErrors appended in the message for other sub-agent failures that derailed the flow.
- Ensure the sub-agent has access to the save-workflow tool and a capable model.
Defensive patterns
Strategy: try-catch
Try / catch
try { const res = await createWorkflowTool.execute({ request }, { mastra }); } catch (e) { if (e.message.includes('never called save-workflow')) { /* retry with explicit instruction to call save-workflow */ } else throw e; } Prevention
- Instruct users/prompts to require an explicit save-workflow call before finishing.
- Use a capable model for the builder sub-agent so it follows the tool-call protocol.
- Verify the sub-agent has save-workflow in its tool allowlist.
When it happens
Trigger: saveAttempted === false after the sub-agent stream completes — the model answered with a summary but never called the save-workflow tool.
Common situations: Model decided to explain the workflow instead of saving; weak prompt so the agent skipped the save step; model lacking permission/routing to call save-workflow.
Related errors
- create-workflow failed: save-workflow threw ${saveErrors.len
- create-workflow failed: save-workflow was called but did not
- @mastra/livekit: no workflow specified. Set `workflow` on cr
- create-workflow requires a Mastra context.
- The "workflow-builder" sub-agent is not registered on this M
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/aeb06cb759cadf37.
Report an issue: GitHub.