Skip to main content

Creating Nodes

Nodes are the building blocks of workflows - callable functions that transform data and can be chained together into execution graphs.

Node Decorator

The @node decorator converts functions into workflow nodes:

Node Names

Node names are used for:
  • Result storage in shared state
  • Debugging and logging
  • Graph visualization

Parameter Mapping

Nodes automatically map previous node outputs to input parameters using intelligent type-based mapping:

Single Parameter

Single-parameter nodes receive the entire previous output:

Multiple Parameters with Tuple/List

Multiple parameters map positionally from tuple/list outputs:

Multiple Parameters with Dict

Multiple parameters map by name from dict outputs:

Shared State Parameter

Nodes can access shared state by adding a SharedState parameter:
Important: Only one SharedState parameter allowed per node.

Decision Nodes

Decision nodes route execution based on runtime conditions:

Pattern Matching

Decision nodes support pattern matching for complex routing:

Parallel Nodes

Parallel nodes execute multiple operations concurrently:

Node Classes

BaseNode

All nodes inherit from BaseNode:

AsyncNode

For async operations:

BatchNode

For batch processing:

Node Attributes

Nodes can have custom attributes:

Node Registry

Nodes are automatically registered by name:

Type Hints

Type hints enable automatic validation and documentation:

Best Practices

Node Lifecycle

Understanding node execution:

Performance Considerations

  • Function overhead: Less than 0.1ms per node call
  • Parameter mapping: Cached for performance (6x speedup)
  • State access: O(1) dictionary lookups
  • Type checking: Disabled by default in production

Error Handling

Nodes can raise exceptions to halt workflow execution:

What’s Next?

Parallel Execution

Execute nodes concurrently

Shared State

Share data across nodes

Validation

Validate workflows before execution

Type Safety

Type checking for workflows