{"record":{"id":"aeb06cb759cadf37","repo":"mastra-ai/mastra","slug":"create-workflow-failed-the-workflow-builder-sub-a","errorCode":null,"errorMessage":"create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\n\nSub-agent summary:\n${summary}","messagePattern":"create-workflow failed: the workflow-builder sub-agent never called save-workflow\\. No workflow was persisted\\.(.+?)\n\nSub-agent summary:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/tools/workflows/create-workflow.ts","lineNumber":114,"sourceCode":"\n    // If save-workflow errored, surface that error explicitly — do NOT return\n    // the sub-agent's summary as if things were fine.\n    const saveErrors = toolErrors.filter(e => e.toolName === 'save-workflow');\n    if (saveErrors.length > 0 && !saveSucceeded) {\n      throw new Error(\n        `create-workflow failed: save-workflow threw ${saveErrors.length} error(s):\\n- ${saveErrors\n          .map(e => e.error)\n          .join('\\n- ')}\\n\\nSub-agent summary (unreliable, save did not succeed):\\n${summary}`,\n      );\n    }\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":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/tools/workflows/create-workflow.ts#L96-L132","documentation":"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.","triggerScenarios":"saveAttempted === false after the sub-agent stream completes — the model answered with a summary but never called the save-workflow tool.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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."],"tags":["workflows","sub-agent","missing-tool-call"],"backgroundTag":"required-tool-call-not-made","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}