SUB_WORKFLOW node does that: for each message it receives, it runs another stored workflow of the same session, waits for it, and emits one message with the outcome.
Two reasons to use one
Reuse. If three workflows all end with the same “notify, then record” sequence, do not copy it. Extract it once and call it. Change it in one place. Loops, within limits. A workflow graph has no cycles, so it cannot say “do this again until it works”. A sub-workflow is the escape hatch: move one round of work into its own workflow, and run it again from a parent. Because nesting is capped (five levels), the loop is bounded by construction. For an AI agent that may need several rounds, that cap is a safety feature as much as a limitation.What a child run is
The child is a perfectly ordinary run. It has its own id and is tracked, logged and audited like any other. What ties it to the parent is that it runs inside the parent’s node: its start payload is whatever the node passes, and cancelling or stopping the node cancels the child. How the parent hears back is the interesting design choice. By default a failing child fails the node, so the parent’s failure model applies: retries, error routing and time limits work as for any node. Or the node can route on how the child ended, sending the message outsuccess, failure, retry or escalate, so the parent can branch on the result, for example retry a stage or hand it to a person. The first treats the child as a black box that may throw; the second treats it as a step that reports an outcome. Choose by whether the parent should react to a failure or only be failed by it.
Costs and limits
- Same session only. A child must be a workflow of the same session. That keeps ownership, keys and fairness simple.
- A child uses its parent’s slot. When concurrency is limited, a child runs on the slot its parent already holds and is not counted against the limits. Otherwise a parent waiting for its children could starve them. The cost is that child runs do not show up in the running count.
- Depth is capped at five. Deeper nesting is refused.
- Not on remote workers. A sub-workflow node cannot be placed on a remote worker.
- A new layer to debug. A failure inside a child is one level further from where you are looking. Each child has its own run to inspect.
When not to use one
Do not extract a workflow for two nodes you use once; the indirection costs more than the copy. Do not use a sub-workflow to loop over one call: a loop node suits polling and retrying a single processor. And if the child exists only to do something once per message, check that a splitter and ordinary nodes would not read more plainly.Related
- Run a sub-workflow: the how-to.
- Runs and AI and deterministic work: agent loops.
- Routing and flow reference: the node’s options.