createParallelStep and createForEachStep let you run multiple sub-steps concurrently. Combine them to transform lists or aggregate analytical workloads efficiently.
Need to parallelise full workflow branches (each with multiple steps)? Use the builder-levelbranchParallelhelper instead ofcreateParallelStep. The two features target different layers.
Chunking pipeline
createForEachStep returns an array by default—set collect when you need to merge the results (for example to concatenate embeddings). TChunkDocument ensures consistent chunking and propagates metadata (source: "raw-text").
Manage concurrency
concurrencyincreateForEachSteplimits how many items run in parallel (defaults to1). Increase it when handlers are I/O bound.- Steps declared in
createParallelSteprun simultaneously and their outputs are grouped into an object. - Mix
parallelandforeachto optimise pipelines without sacrificing readability.
Observability
Every nested execution emits events (step:parallel:start, step:parallel:success, …). Watch them with run.watch() to monitor which branches are active and how long they take.
Need dynamic decisions? Read Conditional branches. Want to loop until a predicate is met? Head to While loops.