Skip to content

Workflow

junjo.Workflow

Kind: Class

SDK version: 0.64.0

Documentation channel: Next source preview

Workflow(graph_factory: GraphFactory[Graph], store_factory: StoreFactory[StoreT], max_iterations: int = 100, hooks: Hooks | None = None, name: str | None = None)

View source

A Workflow is a top-level, executable collection of nodes and edges arranged as a graph. It manages its own state and store, distinct from any parent or sub-workflows.

This class is generic and requires two type parameters for a convenient and type-safe developer experience:

StateT is the type of state managed by this workflow and should be a subclass of BaseState. StoreT is the store type used by this workflow and should be a subclass of BaseStore.

Every call to execute creates a fresh graph, a fresh store, and a fresh execution context. That makes a Workflow instance a reusable definition or blueprint rather than a mutable live-run container.

Name Type Description Default
name str | None An optional name for the workflow. If not provided, the
class name is used.
None
graph_factory GraphFactory[Graph] A callable that returns a new instance of the
workflow’s graph (Graph). This factory is invoked at the
beginning of each execute call to
ensure a fresh, isolated graph for that execution.
store_factory StoreFactory[StoreT] A callable that returns a new instance of the
workflow’s store (StoreT). This factory is invoked at the
beginning of each execute call to
ensure a fresh store for that execution.
max_iterations int The maximum number of times any single node or
subflow may run within one workflow execution. For
RunConcurrent, Junjo counts each
child item in the concurrent group rather than the
RunConcurrent wrapper itself. This helps detect accidental
loops. Defaults to 100.
100
hooks Hooks | None An optional Hooks registry for
observing workflow lifecycle events. Hooks are optional observers;
they do not control OpenTelemetry instrumentation or workflow
execution.
None