haive.core.graph.node.stateful_node_config¶
Stateful Node Configuration - Enhanced Dynamic Architecture.
This module provides a truly dynamic node architecture where: - All routing destinations are discovered from state at runtime - Field configurations are dynamically resolved from state - Engine references, tool references, and node references are all stateful - Nodes adapt their behavior based on what’s available in state
Key Features: - Runtime discovery of engines, tools, and routing destinations - Dynamic field mapping configuration - Stateful routing with fallback mechanisms - Type-safe parameter extraction with automatic field detection
Classes¶
Base class for stateful nodes that discover resources from state at runtime. |
|
Stateful parser node that discovers routing from state. |
|
Stateful tool node that discovers tools from state. |
|
Stateful validation node that discovers everything from state. |
Module Contents¶
- class haive.core.graph.node.stateful_node_config.StatefulNodeConfig(/, **data)¶
Bases:
haive.core.graph.node.base_node_config.BaseNodeConfig,abc.ABCBase class for stateful nodes that discover resources from state at runtime.
This class provides the foundation for truly dynamic nodes that: - Discover engines by name or type from state - Resolve routing destinations based on state configuration - Adapt field mappings based on available state fields - Handle fallback mechanisms when resources are not found
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- discover_engine(state)¶
Discover engine from state using multiple strategies.
- Parameters:
state (haive.core.graph.common.types.StateLike) – State object to search for engines
- Returns:
Engine instance or None if not found
- Return type:
Any | None
- discover_field_mapping(state, callable_func=None)¶
Discover field mapping from state and function signatures.
- discover_routing_destination(state, route_key)¶
Discover routing destination from state configuration.
- abstractmethod execute_stateful_logic(state, config=None)¶
Execute the node’s stateful logic.
This method should be implemented by subclasses to provide the actual node functionality using the discovered resources.
- Parameters:
state (haive.core.graph.common.types.StateLike) – Current state
config (haive.core.graph.common.types.ConfigLike | None) – Optional configuration
- Returns:
Command object with updates and routing
- Return type:
langgraph.types.Command
- class haive.core.graph.node.stateful_node_config.StatefulParserNodeConfig(/, **data)¶
Bases:
StatefulNodeConfigStateful parser node that discovers routing from state.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- execute_stateful_logic(state, config=None)¶
Execute parser logic with dynamic discovery.
- Parameters:
state (haive.core.graph.common.types.StateLike)
config (haive.core.graph.common.types.ConfigLike | None)
- Return type:
langgraph.types.Command
- class haive.core.graph.node.stateful_node_config.StatefulToolNodeConfig(/, **data)¶
Bases:
StatefulNodeConfigStateful tool node that discovers tools from state.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- execute_stateful_logic(state, config=None)¶
Execute tool logic with dynamic discovery.
- Parameters:
state (haive.core.graph.common.types.StateLike)
config (haive.core.graph.common.types.ConfigLike | None)
- Return type:
langgraph.types.Command
- class haive.core.graph.node.stateful_node_config.StatefulValidationNodeConfig(/, **data)¶
Bases:
StatefulNodeConfigStateful validation node that discovers everything from state.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- execute_stateful_logic(state, config=None)¶
Execute validation logic with dynamic discovery.
- Parameters:
state (haive.core.graph.common.types.StateLike)
config (haive.core.graph.common.types.ConfigLike | None)
- Return type:
langgraph.types.Command