Skip to main content

Branch & loop

Why you need it

Business logic branches and loops. Those routes must themselves be durable so recovery does not guess the next action.

Code examples

Choose an SDK (preference is sticky in this browser; default Python).

def execute(self, context, input):
if input.ok:
return go_to(SuccessStep(), input)
return go_to(self, input.retry()) # loop

Return a StepDecision that moves to another Step (or the same Step) with an input.

How Dex implements it

The Dex interpreter records Step movements in Temporal/Cadence history and schedules the next Step execution. Loops are explicit go_to movements, not hidden polling threads.

Traditional workarounds

Without Dex, engineers encode branches in job tables, state machines in YAML, or ad-hoc “status” enums updated by cron workers.