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¶

StatefulNodeConfig

Base class for stateful nodes that discover resources from state at runtime.

StatefulParserNodeConfig

Stateful parser node that discovers routing from state.

StatefulToolNodeConfig

Stateful tool node that discovers tools from state.

StatefulValidationNodeConfig

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.ABC

Base 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.

Parameters:
  • state (haive.core.graph.common.types.StateLike) – State object to analyze

  • callable_func (callable | None) – Function to analyze for parameter mapping

Returns:

Dictionary mapping parameter names to state field names

Return type:

dict[str, str]

discover_routing_destination(state, route_key)¶

Discover routing destination from state configuration.

Parameters:
  • state (haive.core.graph.common.types.StateLike) – State object to search

  • route_key (str) – Key to look for (e.g., ‘tool_node’, ‘parser_node’)

Returns:

Node name to route to or None if not found

Return type:

str | None

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: StatefulNodeConfig

Stateful 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: StatefulNodeConfig

Stateful 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: StatefulNodeConfig

Stateful 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