MastraM
Mastra3mo ago
wiz2202

Workflow Snapshots

I am basically trying to reconnect to a running workflow. I use the watch and pass it the runID, but the issue is that when I reconnect, I am not aware of the current state of the workflow, so my ui can not refelect the state of the workflow until the next stream comes through. I tried to make a workaround where I get the snapshot and that can tell me where I am so I can initally show that state, but the snapshots do not handle parallel steps well from what I did.

i did this test to find the problem:
Here was the test workflow:
export const testSimpleWorkflow = createWorkflow({
id: "testSimpleWorkflow",
description: "Test workflow mirroring refreshUrlWorkflow structure",
inputSchema: TestInputSchema,
outputSchema: TestOutputSchema,
})
.then(getUrlOutlineWorkflowTest)
.parallel([
keywordAnalysisWorkflowTest,
serpResearchWorkflowTest,
refreshURLRedditResearchWorkflowTest,
])
.then(comprehensiveSynthesisStepTest)
.commit();


async function fetchSnapshot(runId: string) {
const store = mastra.getStorage();

if (!store) {
throw new Error("Storage not configured");
}

const workflowRun = await store.getWorkflowRunById({
runId,
workflowName: "testSimpleWorkflow",
});

if (!workflowRun || !workflowRun.snapshot) {
throw new Error("Workflow run not found");
}

return workflowRun.snapshot as {
status: string;
context?: Record<string, any>;
};
}

BELOW YOU CAN SEE THE SNAPSHOTS THAT WERE REUNTED USING THE ABOVE METHOD AT DIFFERENT POINTS IN WORKFLOW: Overarching issue is that I assumed that the output to the snapshots would contain all the currently running workflows. However, these are only returning one of the ones in parallel, not all of them. I did some more digging adn they are running in parallel, but the workflow snapshots do not show all 3 steps as active?
Screenshot_2025-10-19_at_4.02.41_PM.png
Screenshot_2025-10-19_at_4.02.55_PM.png
Screenshot_2025-10-19_at_4.03.06_PM.png
Was this page helpful?