Help: Cannot stream anything from workflows after recent update

Setup:

  • FE:
    useChat
    hook calling Fastify endpoint
  • BE: Custom endpoint using run.streamVNext({ inputData }) then toAISdkFormat(workflowStream, { from: 'workflow' })
  • Versions: @mastra/core@0.23.3, @mastra/ai-sdk@0.2.5
My workflow step:

execute: async ({ mastra, writer, ... }) => {
  const agent = mastra?.getAgent('generalInquiryAgent');
  const stream = await agent?.stream(messages, { runtimeContext });
  await stream!.textStream.pipeTo(writer!); // Text goes to workflow writer
  return { textResponse: await stream!.text };
}


My endpoint:

const workflowStream = await run.streamVNext({ inputData: { messages, userData } });
const aiSdkStream = toAISdkFormat(workflowStream, { from: 'workflow' });
return createUIMessageStreamResponse({ stream: aiSdkStream });


The problem:
toAISdkFormat with from: 'workflow' only emits data-workflow events (workflow metadata). The text I pipe via writer.write() shows up in workflow-step-output within those data-workflow payloads, but it's never extracted into text-delta events that
useChat
expects.

Without writing hundreds of lines of manual stream transformation code to parse data-workflow events and extract text from nested workflow-step-output, I can't get text streaming to work. This feels like it should "just work" - I'm using the recommended toAISdkFormat utility and piping agent text to the workflow writer as shown in the docs.

Question:
Is there a built-in option/flag/way to get text-delta events from workflow text output? Or is manual transformation the only path forward? If manual, what's the recommended/simplest approach?
Was this page helpful?