File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 44from typing import Any , Optional , Type
55
66from langchain_core .runnables import RunnableConfig , RunnableLambda , RunnablePassthrough
7+ from langchain_core .runnables .base import RunnableLike
78
89from langgraph .channels .base import BaseChannel , InvalidUpdateError
910from langgraph .channels .binop import BinaryOperatorAggregate
@@ -25,12 +26,17 @@ def __init__(self, schema: Type[Any]) -> None:
2526 if any (isinstance (c , BinaryOperatorAggregate ) for c in self .channels .values ()):
2627 self .support_multiple_edges = True
2728
29+ def add_node (self , key : str , action : RunnableLike ) -> None :
30+ if key in self .channels :
31+ raise ValueError (
32+ f"'{ key } ' is already being used as a state attribute "
33+ "(a.k.a. a channel), cannot also be used as a node name."
34+ )
35+ return super ().add_node (key , action )
36+
2837 def compile (self , checkpointer : Optional [BaseCheckpointSaver ] = None ) -> Pregel :
2938 self .validate ()
3039
31- if any (key in self .nodes for key in self .channels ):
32- raise ValueError ("Cannot use channel names as node names" )
33-
3440 state_keys = list (self .channels )
3541 state_keys_read = state_keys [0 ] if state_keys == ["__root__" ] else state_keys
3642 update_state = (
You can’t perform that action at this time.
0 commit comments