M
MastraAI•4w ago
Steffen

Distinguish Step Level Retries / Workflow Level Retries

iam trying to find a way when inside a step iam using retries how to distinguish the - workflow level retries - step level retries according to the documentation runCount gets ovveridden when retries are used ( in a step )... Basicalyl i need to distinguish this in order to know if only a step failed 3 times for example or if the entire workflow failed 3 times. Because i want to apply some error logic when 3 workflow level retries fail not Acces runcount in a step --> by default its the workflow level retries / if retries is set it is step level retries
execute: async ({ inputData, runtimeContext, runCount }) => {
execute: async ({ inputData, runtimeContext, runCount }) => {
const generateLessonPlanStep = createStep({
id: "generate-lesson-plan",
description:
"Generate lesson plan using direct generateText call and Portkey prompts",
retries: 3, // Step-level retry for AI generation and JSON parsing failures
const generateLessonPlanStep = createStep({
id: "generate-lesson-plan",
description:
"Generate lesson plan using direct generateText call and Portkey prompts",
retries: 3, // Step-level retry for AI generation and JSON parsing failures
looking at the error handling docs there is a workflow watch but which maybe could give me the final result / failure ?? but i was attempting to use this without that just using the runcount https://mastra.ai/en/docs/workflows/error-handling
5 Replies
Steffen
SteffenOP•4w ago
@Tyler @Romain
_roamin_
_roamin_•4w ago
Hey @Steffen ! I think you could leverage the runtimeContext to store the info you need runtimeContext.set('your-key', 'your-value'). You can then update that value whenever you need.
Steffen
SteffenOP•4w ago
iam doing that already . but that still means i have to manually determine if the runcount is from a step or is from the workflow. I was hoping there is some kind of metadata or something that tells me if runcount is currently from a step or from the workflow . It would save me have to manuelly determine this for every step basically i have funciton i pass this runcount to and by itself i cant determine if its step or workflow runcount šŸ˜„ ... @Romain thanks though . i will keep my current setup in that case then šŸ™‚ 🌻
_roamin_
_roamin_•4w ago
Hey @Steffen ! Unfortunately, I don't think that's possible with the current implementation of runCount. Could you open a feature request on GH? Thanks šŸ™
Steffen
SteffenOP•4w ago
ok yes thanks made a request

Did you find this page helpful?