

ctx.run_node, which returns an awaitable for invoking another node. Gather those awaitables into a list and hand them to asyncio.gather to run them concurrently and wait for all to finish. This pattern gives you runtime fan-out with an implicit join when all tasks complete.
checks_for(ticket)determines the branch count at runtime.ctx.run_nodereturns an awaitable for each branch.asyncio.gather(*tasks)starts all tasks and waits for them to finish, giving you dynamic fan-out and a join.

- Use a static graph when you know the workflow shape ahead of time:
- Fixed pipelines (same steps every run)
- Routers with a known set of branches
- Fan-out across a fixed set of sources
- Use a dynamic workflow when control flow depends on runtime data:
- Loops that iterate an unknown number of times
- Fan-out whose branch count depends on the input
- Any case where you’d write
while,for, orifin Python to describe control flow
Before you deploy dynamic workflows to production, avoid a common Python mistake that subverts automatic retries.
Imagine a
while loop that keeps invoking the quality-check node until the item is clean. What happens if one of those calls fails transiently — an API timeout or a rate-limit error? The runtime can automatically retry a node that fails by raising an exception, but only if it sees the exception.
A problematic habit is wrapping the entire node in a broad except Exception that swallows all errors, logs them, and returns a fallback value. For example:
None. From the runtime’s perspective, the node succeeded — no exception escaped — so it won’t retry. You have converted a recoverable transient failure into a silent “fake success.”

try/except only when you have a specific recovery or compensating action to perform; never wrap the entire node body in a blanket except that hides all errors.
Avoid broad
except Exception blocks that swallow transient errors you want the runtime to retry. Let real failures raise so the runtime can retry the node.- Static graphs are ideal when the workflow structure is stable and known ahead of time.
- Dynamic fan-out gives you flexible concurrency — build the set of awaitables at runtime and use
asyncio.gatherto execute them concurrently and join. - Never hide errors you want the runtime to manage; let transient exceptions bubble up so automatic retries can happen.
- asyncio.gather — Python docs
- Python Basics — KodeKloud course
- Runtime and workflow docs (refer to your platform-specific documentation for
ctx.run_nodeand retry behavior)