Nested Workflow with custom writer
Workflow -> .branch(condition, nestedWorkflow)
in nestedWorkflow -> createStep -> writer.custom
toAISDK(workflow.run().stream(), {from:workflow})
the writer isn't propagating the custom data-* to root stream
30 Replies
š Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10433
š If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly.
š Thank you for helping us improve Mastra!
I think i face the same problem
This worked for me for now.
@Ward this is the same issue as what I was facing when I reported this issue, which you fixed
What the exact problem is then i dont know, but this is still happening apparently
@Vulcano
Based on @arpitBhalla code i patched the ai-sdk transformer as i use
useChat and not client side runs
This seems to emit events in resume for meSick, ill give it a try when I have time to see if this fixes my issue as well. I also use the AI SDK v5 useChat
i think this fix is in draft: https://github.com/graysonhicks/mastra/pull/2/files#diff-ad190027209ea2bf18b9a2afabef641af4fb6f2251bdbab449a8bf565c1722bf
GitHub
Fix workflow-step-output handling in ai-sdk transformers by grayson...
Description
Added explicit handling for workflow-step-output chunk type in AI-SDK transformers. This ensures that chunks from nested workflow steps, including embedded data-* chunks or the original...
I'm not sure if this will fix the nested workflow issue.
Could you try this in
createUIMessageStream
this will work without patching the @mastra/ai-sdkThanks for the investigation! We'll get it fixed!
@arpitBhalla this does fix one of my issues, but the stream.fullStream in my case sometimes simply doesnt even contain some writer.custom events under very specific circumstances, so I will await the release that fixes this and see if that issue also gets fixed
@Dero we should check if writer.custom works in any primitive (tool, workflow, agent) cause it should be fixed in the latest version of mastra core and ai-sdk
Dero opened a PR here https://github.com/mastra-ai/mastra/pull/10447
GitHub
fix/workflow step output data chunks by TheIsrael1 Ā· Pull Request ...
fix(ai-sdk): propagate custom data chunks from nested workflows in branches to root stream
changeset
Description
Related Issue(s)
Type of Change
Bug fix (non-breaking change that fixes an issu...
This will be released in our next 0.x release 1.0.0-beta release tomorrow
Hi, I'm still unable to get it for nested workflows.
Hi @arpitBhalla I have tested the original example you linked here
and can verify it works with the latest
0.x
We are going to ship an example for it in the UI Dojo. A PR is already open https://github.com/mastra-ai/ui-dojo/pull/13
If this is not exactly what you are trying to achieve, kindly help with more of your implementation detail š@dero is this fix released in v1 beta now?
both beta and latest
@arpitBhalla were you able to fix this? for me when a nested workflow is resumed no custom events are emitted
I'm still using custom transformer
@dero it seems to be broken with resume
@Ward would be great to post the PR here once its up so i can temp patch until the release
When i inspected to stream workflow-step-output was not there on resume
ye my issue was also with resuming nested workflows and that is still an issue
Okay let me reopen this
GitHub
fix(workflows): pass writable stream to workflow resume by roaminro...
Description
Add missing writableStream parameter when resuming workflows to ensure
output is properly streamed during workflow execution.
Related Issue(s)
slack
Type of Change
Bug fix (non-breaki...
@Ward can confirm it works for me
š
Yayyyyyy
I will also try it out tomorrow!
@Ward when can we expect this fix in beta release š
I think it's already released..
it's released in beta on wednesday morning GMT+1
let me know if it hasn't been fixed yet