Workflow Parallel Template
The Workflow Parallel template demonstrates how a BindAI workflow can fan out from one node into multiple workflow paths and synchronize those paths with aJoinNode.
A ParallelNode acts as a branching point. The workflow executor adds all of the node’s outgoing next_nodes to the execution queue.
A JoinNode can then track how many branch arrivals have reached it before allowing execution to continue.
Important: The current ParallelNode is a workflow fan-out mechanism. It does not create separate workflow contexts or launch branches in separate threads by itself.
Purpose
This template demonstrates how to:- Create multiple workflow branches
- Fan out execution from a
ParallelNode - Process branch nodes through the workflow executor
- Synchronize branches with a
JoinNode - Track branch-specific results in workflow variables
- Coordinate independent workflow operations
Workflow Structure
A typical parallel workflow can be represented as:ParallelNode provides the branching point.
The JoinNode provides synchronization after the branches reach it.
There is no special built-in StartNode or EndNode required for this pattern.
ParallelNode
A parallel node can be created with:execute() method simply returns the existing workflow context:
next_nodes.
Fan-Out Execution
When the workflow executor completes a node, it normally adds that node’snext_nodes to the execution queue.
For a ParallelNode, this means multiple outgoing nodes can be scheduled:
ParallelNode itself does not start threads or create independent workflow executions.
Execution Model
The current execution model is better understood as workflow fan-out rather than automatic concurrent execution. Conceptually:Independent Branches
Parallel-style branching is useful when several operations do not depend directly on one another. For example:JoinNode
AJoinNode synchronizes branch arrivals.
It is created with an expected number of arrivals:
expected value determines how many times the join must be reached before it stops waiting.
For three branch arrivals:
Join State
TheJoinNode keeps track of arrivals using:
Waiting
When the number of arrivals is still belowexpected, the JoinNode sets:
JoinNode waiting states so that branch completion does not behave like a normal workflow-wide wait.
Shared Workflow Context
Parallel branches use the same workflow context. Conceptually:Avoiding Conflicting Writes
Because branches share workflow state, branch-specific data should generally use separate variable names. Prefer:Combining Results
TheJoinNode does not combine branch results.
Its responsibility is synchronization.
For example:
Example
A multi-step analysis workflow could be structured as:Configuring Branches
TheParallelNode uses the normal WorkflowNode.next_nodes mechanism.
Conceptually:
Configuring the Join
For three branch arrivals:Join Arrival Counting
Every time theJoinNode executes, it increments its arrival count:
Parallel vs Sequential
Parallel-style fan-out is useful when several branches can be represented independently.Sequential
Fan-Out
Parallel vs Condition
A condition selects one of two configured paths. A parallel node schedules all of its outgoing paths.
A condition is appropriate when only one path should execute.
A parallel node is appropriate when multiple paths should be processed.
Synchronization with Join
A Join node is useful when downstream execution should wait for multiple branch arrivals. Conceptually:Error Handling
ParallelNode and JoinNode do not implement their own branch-specific failure strategy.
Exceptions raised by workflow nodes are handled by WorkflowExecutor.
If no retry policy is configured, a node failure causes workflow failure.
If a retry policy is configured, the executor can retry the failing node until its configured attempt limit is reached.
The current parallel implementation should therefore not be described as automatically isolating failed branches or producing partial results.
Combining with Retry
A branch can participate in normal workflow retry behavior. Conceptually:ParallelNode.
Combining with Timeout
Timeout policies are also handled by the workflow executor. A parallel-style workflow can therefore use timeout configuration around its normal node execution. For example:ParallelNode itself.
Typical Use Cases
This pattern can be useful for:- Independent analysis steps
- Multiple retrieval operations
- Separate validation paths
- Independent API operations
- Multi-agent analysis
- Document-processing branches
- Data preparation steps
- Workflows that collect several results before continuing
Important Implementation Boundaries
No separate workflow contexts
The currentParallelNode does not create a new WorkflowContext for each branch.
All branches operate on the workflow’s existing context.
No automatic threads
TheParallelNode does not create threads or use a thread pool.
It simply returns the context.
The workflow executor schedules the node’s outgoing next_nodes.
Branches share variables
Because branches use the same context, writes to shared variables can interact with one another. Use branch-specific variable names where appropriate.Join counts arrivals
JoinNode tracks arrivals using:
Join does not merge results
The Join synchronizes branch arrivals. It does not combine, transform, or summarize branch outputs.Expected count must match the workflow
Theexpected value should represent the number of branch arrivals that the workflow intends to synchronize.
An incorrect value can cause the join to wait for an arrival that never occurs or to release before all intended branches have arrived.
Best Practices
- Use parallel fan-out only when multiple paths can be handled independently.
- Configure branch-specific result variables.
- Avoid conflicting writes to shared workflow variables.
- Set
JoinNode.expectedto the intended number of arrivals. - Ensure every expected branch can actually reach the join.
- Use a Join when downstream work depends on multiple branch arrivals.
- Keep branch logic focused.
- Use retry policies for transient node failures.
- Test each branch independently.
- Test the complete fan-out and synchronization path.
- Remember that the current
ParallelNodeis fan-out scheduling, not automatic concurrent execution.
Related Templates
The parallel workflow pattern builds on:08.1 workflow-basic.md08.2 workflow-condition.md08.3 workflow-loop.md
08.5 workflow-human.md08.6 workflow-retry.md08.7 workflow-timeout.md08.8 workflow-schedule.md
Summary
The Workflow Parallel template introduces fan-out and synchronization into BindAI workflows. The essential pattern is:ParallelNode provides the branching point by allowing all of its outgoing next_nodes to be added to the workflow execution queue.
A JoinNode tracks how many branch arrivals have reached it. Until the configured expected count is reached, the join enters a waiting state.
Branches use the same workflow context, so branch-specific results should be stored carefully.
The current implementation provides workflow-level fan-out and synchronization; it does not create independent workflow contexts or automatically execute branches concurrently.