Workflow Nodes
Workflow nodes are the building blocks of MoFA workflows. This page documents all node types, reducer implementations, and execution policies.NodeFunc Trait
The core trait for implementing custom workflow nodes.Trait Definition
Parameters
Mutable reference to the current workflow stateThe node can read from and modify the state directly, but state updates returned in the
Command are the recommended approach.Runtime context with execution metadataAvailable information:
execution_id: Unique execution identifiergraph_id: Graph identifiercurrent_node: Current node being executedremaining_steps: Steps remaining before recursion limitconfig: Graph configurationmetadata: Custom metadatatags: Execution tags
Return Value
Returns a
Command containing:- State updates to apply
- Control flow directive (continue, goto, return, send)
- Optional routing decision for conditional edges
Node Types
MoFA provides several built-in node types for common workflow patterns.Start Node
Entry point of the workflowCharacteristics:
- No execution logic
- Passes input through unchanged
- Must exist exactly once per workflow
End Node
Exit point of the workflowCharacteristics:
- No execution logic
- Passes input through unchanged
- Marks workflow completion
- Can have multiple end nodes
Task Node
Executes custom logicCharacteristics:
- Accepts async closure for execution
- Supports retry policy
- Configurable timeout
Agent Node
Invokes an LLM agentCharacteristics:
- Integrates LLM agents into workflows
- Supports prompt templates
- Automatic input/output conversion
Condition Node
Evaluates a boolean condition for branchingCharacteristics:
- Returns “true” or “false” as string
- Used with conditional edges
- Evaluates synchronously
Parallel Node
Fan-out marker for parallel executionCharacteristics:
- Dispatches to multiple parallel branches
- Each branch receives isolated state snapshot
- Execution controlled by
add_parallel_edges
Join Node
Waits for multiple branches to complete and aggregates resultsCharacteristics:
- Waits for all specified nodes to complete
- Optional transform function to combine outputs
- Default behavior merges into Map
Loop Node
Executes logic repeatedly while condition is trueCharacteristics:
- Loop body executor
- Loop condition evaluator
- Maximum iteration limit
- State carried between iterations
Transform Node
Transforms data without side effectsCharacteristics:
- Pure transformation function
- Receives map of inputs
- Returns transformed value
SubWorkflow Node
Invokes another workflow as a sub-workflowCharacteristics:
- References workflow by ID
- Passes input to sub-workflow
- Returns sub-workflow output
Wait Node
Waits for external eventCharacteristics:
- Pauses execution
- Waits for specified event type
- Resumes when event received
Reducers
Reducers control how state updates are merged with existing values.Reducer Trait
Built-in Reducers
Replaces current value with update (default behavior)
Appends update to a list (creates list if doesn’t exist)
Extends list with items from another list
Merges objects (shallow or deep)
Keeps only the last N items in a list
Keeps the first non-null value (ignores subsequent updates)
Keeps the last non-null value
Custom reducer using a closure
Retry Policies
Configure retry behavior for fault tolerance.RetryPolicy
Defines retry behavior for node executionFields:
Maximum number of retry attempts
Delay between retries in milliseconds
Whether to use exponential backoff (doubles delay each retry)
Maximum delay cap in milliseconds
Node Configuration
Configure individual node behavior.NodeConfig
Per-node configurationFields:
Unique node identifier
Human-readable node name
Node type (Start, End, Task, Agent, etc.)
Node description
Retry policy for this node
Timeout configuration
Custom metadata key-value pairs
TimeoutConfig
Complete Example
See Also
- StateGraph API - Graph building and execution
- Workflow DSL - YAML-based workflow configuration
- Command API - Control flow and state updates