suspend will repeat waitForEvenr
Basically I have a step in my workflow which needs to wait before it is given permission to execute however this step also has hitl suspend. The issue I face is I want it to waitForEvent only once before it executes the step and then go into execution and hitl until it can go to next step. I'm having it hard wrapping my head around the best pattern to approach this. My root problem is I'm building a workflow which follows a user journey into phases. Once a phase ends the user enters the next phase. I could in theory split this into separate workflows however I want a clear vision of a users journey as seen in mastra studio do let me know if there is an alternative?
4 Replies
š Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10419
š 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!
Hey Mehul! Sounds like a cool project.
Here's what I'd recommend - keep the waiting and the executing separate: The thing is, waitForEvent and suspend() are different use cases: waitForEvent: "Hey workflow, don't move forward until I get this signal" (workflow-level) suspend(): "Hey step, pause what you're doing right here until someone tells you to continue" (step-level) Trying to combine them in one step gets messy because you're mixing workflow control flow with step execution logic. How You'd Actually Use This Let me know if that makes sense and helps you, thanks!
Here's what I'd recommend - keep the waiting and the executing separate: The thing is, waitForEvent and suspend() are different use cases: waitForEvent: "Hey workflow, don't move forward until I get this signal" (workflow-level) suspend(): "Hey step, pause what you're doing right here until someone tells you to continue" (step-level) Trying to combine them in one step gets messy because you're mixing workflow control flow with step execution logic. How You'd Actually Use This Let me know if that makes sense and helps you, thanks!
Dang i thought i had to pass a whole step for wait for event, and wasn't allowed to keep it as simple as passing an object. That keeps things lean! And I'm happy with that š
This will change in v1! we removed waitForEvent in favor of using suspend/resume. The patttern is the same as Grayson mentioned!