haive.core.graph.node.practical_stateful_example¶
from typing import Any, Dict. Practical Stateful Node Example - Real Implementation.
This shows how to practically implement stateful nodes that work with the current SimpleAgent, LLMState, and MetaStateSchema architecture without breaking changes.
The key insight is that the existing architecture already provides most of what we need: - SimpleAgent.engines dict for engine discovery - LLMState.tool_routes for tool routing - MetaStateSchema for agent composition - Existing node *_config classes for patterns
We just need to enhance the discovery mechanisms in the existing nodes.
Classes¶
Enhanced ParserNodeConfig with stateful discovery capabilities. |
|
Enhanced SimpleAgent that uses stateful nodes for dynamic discovery. |
|
Enhanced ValidationNodeConfigV2 with stateful discovery capabilities. |
Functions¶
Show that existing code continues to work unchanged. |
|
Show how stateful nodes work with MetaStateSchema. |
|
Practical example showing how stateful nodes work with current architecture. |
Module Contents¶
- class haive.core.graph.node.practical_stateful_example.StatefulParserNodeV2(/, **data)¶
Bases:
haive.core.graph.node.parser_node_config.ParserNodeConfigEnhanced ParserNodeConfig with stateful discovery capabilities.
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)
- class haive.core.graph.node.practical_stateful_example.StatefulSimpleAgent¶
Bases:
haive.agents.simple.agent.SimpleAgentEnhanced SimpleAgent that uses stateful nodes for dynamic discovery.
- build_graph()¶
Override build_graph to use stateful nodes.
- Return type:
Any
- class haive.core.graph.node.practical_stateful_example.StatefulValidationNodeV2(/, **data)¶
Bases:
haive.core.graph.node.validation_node_config_v2.ValidationNodeConfigV2Enhanced ValidationNodeConfigV2 with stateful discovery capabilities.
This extends the existing ValidationNodeConfigV2 to add dynamic discovery while maintaining full backward compatibility.
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)
- haive.core.graph.node.practical_stateful_example.backward_compatibility_example()¶
Show that existing code continues to work unchanged.
- haive.core.graph.node.practical_stateful_example.meta_state_integration_example()¶
Show how stateful nodes work with MetaStateSchema.
- Return type:
Any
- haive.core.graph.node.practical_stateful_example.practical_stateful_example()¶
Practical example showing how stateful nodes work with current architecture.
- Return type:
Any