{"record":{"id":"e512b4fc9b811b04","repo":"mastra-ai/mastra","slug":"create-workflow-failed-save-workflow-was-called-b","errorCode":null,"errorMessage":"create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\n\nSub-agent summary:\n${summary}","messagePattern":"create-workflow failed: save-workflow was called but did not return (.+?)\\.(.+?)\n\nSub-agent summary:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/tools/workflows/create-workflow.ts","lineNumber":124,"sourceCode":"    }\n\n    // If save-workflow was never called, the sub-agent gave up (or hallucinated\n    // success). Fail loudly so the caller doesn't think a workflow exists.\n    if (!saveAttempted) {\n      const otherErrors = toolErrors.length\n        ? `\\n\\nOther sub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n        : '';\n      throw new Error(\n        `create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n      );\n    }\n\n    // Save was attempted but never returned ok (no tool-result with { ok: true, id }).\n    if (!saveSucceeded) {\n      const otherErrors = toolErrors.length\n        ? `\\n\\nSub-agent tool errors:\\n- ${toolErrors.map(e => `${e.toolName}: ${e.error}`).join('\\n- ')}`\n        : '';\n      throw new Error(\n        `create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\\n\\nSub-agent summary:\\n${summary}`,\n      );\n    }\n\n    return { summary, workflowId };\n  },\n});\n","sourceCodeStart":106,"sourceCodeEnd":132,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/tools/workflows/create-workflow.ts#L106-L132","documentation":"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.","triggerScenarios":"saveAttempted is true but saveSucceeded is false — save-workflow tool results never contained { ok: true } (errored, returned a different shape, or results were lost).","commonSituations":"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.","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)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"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'; }","tryCatchPattern":"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; }","preventionTips":["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."],"tags":["workflows","persistence","sub-agent"],"backgroundTag":"workflow-save-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}