Skip to main content
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-level branchParallel helper instead of createParallelStep. 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

  • concurrency in createForEachStep limits how many items run in parallel (defaults to 1). Increase it when handlers are I/O bound.
  • Steps declared in createParallelStep run simultaneously and their outputs are grouped into an object.
  • Mix parallel and foreach to 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.