mastra-ai/mastra · error
create-workflow failed: save-workflow was called but did not
Error message
create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}
Sub-agent summary:
${summary} What it means
When save-workflow was called but no tool result ever returned { ok: true, id }, create-workflow throws this error. A save attempt without a successful ok result means the workflow may not be durably persisted, so the tool fails loudly instead of returning a summary.
Source
Thrown at mastracode/sdk/src/tools/workflows/create-workflow.ts:124
}
// 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
- Inspect 'Sub-agent tool errors' in the message for the save-workflow failure reason.
- Re-run create-workflow and confirm a final successful save.
- Verify save-workflow's output schema/ok contract matches the version in use (version drift can break ok detection).
Defensive patterns
Strategy: try-catch
Type guard
function isSaveOk(r: unknown): r is { ok: true; id: string } { return !!r && typeof r === 'object' && (r as any).ok === true && typeof (r as any).id === 'string'; } Try / catch
try { const res = await createWorkflowTool.execute({ request }, { mastra }); } catch (e) { if (e.message.includes('did not return { ok: true }')) { /* inspect sub-agent tool errors, then retry */ } else throw e; } Prevention
- Keep mastracode SDK versions aligned so save-workflow's ok contract matches create-workflow's expectations.
- Confirm storage persistence works by saving a trivial workflow first.
- Re-run on failure; partial saves are common with flaky storage.
When it happens
Trigger: saveAttempted is true but saveSucceeded is false — save-workflow tool results never contained { ok: true } (errored, returned a different shape, or results were lost).
Common situations: save-workflow partially failing (validation errors in result rather than thrown error); sub-agent output parsing dropping the tool result; storage returning non-ok responses.
Related errors
- create-workflow failed: save-workflow threw ${saveErrors.len
- create-workflow failed: the workflow-builder sub-agent never
- @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/e512b4fc9b811b04.
Report an issue: GitHub.