The node is followed by one conditional_edges, and the state update is returned at the node. As a result, conditional_edges are updated twice after the return #323

Closed
opened 2026-02-20 17:36:42 -05:00 by yindo · 2 comments
Owner

Originally created by @Panda-eat-meat on GitHub (Nov 27, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

# code likes like this

def add_message(left_message, right_message):
    print("add_message: ", left_message, right_message)
    if isinstance(left_message, list) and isinstance(right_message, list):
        left_message.extend(right_message)
    elif isinstance(left_message, list):
        left_message.append(right_message)
    else:
        left_message = right_message
    print("add_message end: ", left_message)
    return left_message



class MainState(TypedDict):
    history_diag: Annotated[List[Union[UserMessage, SystemMessage, str, int]], add_message]



async def build_graph(self):
    ********some node************

    self.workflow.add_node("node 1", self.node_1)
    self.workflow.add_node("daozhen_node_get_next_question_wrap", self.node_get_next_question_wrap)
    self.workflow.add_edge("daozhen_node_get_next_question", "daozhen_node_get_next_question_wrap")

    self.workflow.add_conditional_edges("daozhen_node_get_next_question_wrap", self.edge_conditional_res_route, ["node 1","node 2"])
    return self



async def edge_conditional_res_route(self, state: MainState):
    if is_end or jump_out:
        return "node 1"
    else:
        return "node 2"



async def node_get_next_question_wrap(self, state: MainState):
    append_message = [1, 2]
    return {"history_diag": append_message}



async def node_1(self, state: MainState):
    print(state["history_diag"])
    # get [1, 2, 1, 2], bug just update once

Error Message and Stack Trace (if applicable)

No response

Description

One node is called node1. Following the node, conditional_edges returns to update one field of the state. As a result, conditional_edges returns are updated twice. But if I insert a node between node1 and conditional_edges that doesn't return anything, it won't repeat

System Info

macbook m3

lang version:
langchain 0.3.7
langchain-anthropic 0.2.3
langchain-core 0.3.15
langchain-text-splitters 0.3.2
langgraph 0.2.53
langgraph-checkpoint 2.0.6
langgraph-checkpoint-postgres 2.0.2
langgraph-sdk 0.1.35
langsmith 0.1.137

Originally created by @Panda-eat-meat on GitHub (Nov 27, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ### Example Code ```python # code likes like this def add_message(left_message, right_message): print("add_message: ", left_message, right_message) if isinstance(left_message, list) and isinstance(right_message, list): left_message.extend(right_message) elif isinstance(left_message, list): left_message.append(right_message) else: left_message = right_message print("add_message end: ", left_message) return left_message class MainState(TypedDict): history_diag: Annotated[List[Union[UserMessage, SystemMessage, str, int]], add_message] async def build_graph(self): ********some node************ self.workflow.add_node("node 1", self.node_1) self.workflow.add_node("daozhen_node_get_next_question_wrap", self.node_get_next_question_wrap) self.workflow.add_edge("daozhen_node_get_next_question", "daozhen_node_get_next_question_wrap") self.workflow.add_conditional_edges("daozhen_node_get_next_question_wrap", self.edge_conditional_res_route, ["node 1","node 2"]) return self async def edge_conditional_res_route(self, state: MainState): if is_end or jump_out: return "node 1" else: return "node 2" async def node_get_next_question_wrap(self, state: MainState): append_message = [1, 2] return {"history_diag": append_message} async def node_1(self, state: MainState): print(state["history_diag"]) # get [1, 2, 1, 2], bug just update once ``` ### Error Message and Stack Trace (if applicable) _No response_ ### Description One node is called node1. Following the node, conditional_edges returns to update one field of the state. As a result, conditional_edges returns are updated twice. But if I insert a node between node1 and conditional_edges that doesn't return anything, it won't repeat ### System Info macbook m3 lang version: langchain 0.3.7 langchain-anthropic 0.2.3 langchain-core 0.3.15 langchain-text-splitters 0.3.2 langgraph 0.2.53 langgraph-checkpoint 2.0.6 langgraph-checkpoint-postgres 2.0.2 langgraph-sdk 0.1.35 langsmith 0.1.137
yindo added the invalid label 2026-02-20 17:36:42 -05:00
yindo closed this issue 2026-02-20 17:36:43 -05:00
Author
Owner

@vbarda commented on GitHub (Jan 14, 2025):

Please provide a minimal reproducible example https://stackoverflow.com/help/minimal-reproducible-example

@vbarda commented on GitHub (Jan 14, 2025): Please provide a minimal reproducible example https://stackoverflow.com/help/minimal-reproducible-example
Author
Owner

@vbarda commented on GitHub (Jan 29, 2025):

Closing due to inactivity

@vbarda commented on GitHub (Jan 29, 2025): Closing due to inactivity
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#323