allow simple mapping functions to be passed in workflow branch handler

// Instead of creating 3+ steps for simple value returns:
.branch([
[condition1, createStep({ /* just returns a string */ })],
[condition2, createStep({ /* just returns another string */ })],
])

// Allow:
.branch([
[condition1, async ({ inputData }) => "result1"],
[condition2, async ({ inputData }) => "result2"],
])
// Instead of creating 3+ steps for simple value returns:
.branch([
[condition1, createStep({ /* just returns a string */ })],
[condition2, createStep({ /* just returns another string */ })],
])

// Allow:
.branch([
[condition1, async ({ inputData }) => "result1"],
[condition2, async ({ inputData }) => "result2"],
])
3 Replies
_roamin_
_roamin_2w ago
Hi! "branch" is to be used with steps/nest workflows. What is your use case?
Guria
GuriaOP2w ago
At the time I wrote this suggestion I wasn't yet aware that result of branch is nested in the object by step id. I was trying to make same type as output in both branches. In this case we can improve docs to indicate how exactly branch affects output
Guria
GuriaOP2w ago
GitHub
[DOCS] workflow methods affecting outputs · Issue #8712 · mastra-...
Describe the Improvement Needed It was unclear for me what is actual output of such methods like branch and parallel without logging runtime values. Documentation Type Missing Information

Did you find this page helpful?