Adding a Branch
Create a branch withadd_branch(). The destination runs after the source completes; the main path continues along its regular edges as if the branch were not there:
Multi-Step Branches
The branch target can lead to further nodes through ordinary edges. Together they form a pipeline that runs to its last step:{"success": False}, the steps after it do not run.
Reading the Previous Node
Every node can declare anupstream parameter. It holds the name and output of the node that ran just before it, so a pipeline step can read what it was given:
upstream is available on the main path too, and nodes that do not declare it are unaffected.
Conditions
Pass acondition to decide at run time whether the branch runs. It receives the source node’s output and the graph state and may be sync or async:
Detached Branches
By default the main path waits for a branch to finish before moving on. Passwait=False to let it continue immediately:
execute() still waits for every detached branch before it returns, so nothing is left running when a run is reported complete.
Errors
An exception inside a branch never reaches the main path. It is logged and recorded on the graph:branch_errors is cleared at the start of each execute().
Branches on Routers and Loops
A branch can hang off any node, including a node inside a router loop. The loop is unaffected because a branch is not one of the node’s successors:Next Steps
- Compare branches with forks in Parallel Execution vs Branching
- Learn how forks and joins work in Parallel Execution
- See how outputs flow between nodes in State

