Visualized graph has wrong conditional edges #198

Closed
opened 2026-02-20 17:31:13 -05:00 by yindo · 5 comments
Owner

Originally created by @minki-j on GitHub (Aug 19, 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

from langgraph.graph import END, StateGraph
from langgraph.checkpoint.memory import MemorySaver
from langchain_core.runnables import RunnablePassthrough
from typing import TypedDict

class State(TypedDict):
    current_step: int
    total_number_of_steps: int

g = StateGraph(State)
g.set_entry_point("entry")

g.add_node("entry", RunnablePassthrough())
g.add_edge("entry", "A")

g.add_node("A", RunnablePassthrough())
g.add_edge("A", "B")

g.add_node("B", RunnablePassthrough())
g.add_edge("B", "reduce_middle_step")

g.add_node("reduce_middle_step", RunnablePassthrough())
g.add_conditional_edges(
    "reduce_middle_step",
    lambda state: (
        END if state["current_step"] >= state["total_number_of_steps"] else "A"
    ),
)

main_graph = g.compile(checkpointer=MemorySaver(), interrupt_after=["B"])


with open("./main_graph.png", "wb") as f:
    f.write(main_graph.get_graph().draw_mermaid_png())

Error Message and Stack Trace (if applicable)

The graph diagram has unspecified connections

Description

Run the code and check the image generated.
It has conditional edges from "recude_middle_step" to "entry", "A", and "B" where I only connected to "A".
main_graph

System Info

not required.

Originally created by @minki-j on GitHub (Aug 19, 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 from langgraph.graph import END, StateGraph from langgraph.checkpoint.memory import MemorySaver from langchain_core.runnables import RunnablePassthrough from typing import TypedDict class State(TypedDict): current_step: int total_number_of_steps: int g = StateGraph(State) g.set_entry_point("entry") g.add_node("entry", RunnablePassthrough()) g.add_edge("entry", "A") g.add_node("A", RunnablePassthrough()) g.add_edge("A", "B") g.add_node("B", RunnablePassthrough()) g.add_edge("B", "reduce_middle_step") g.add_node("reduce_middle_step", RunnablePassthrough()) g.add_conditional_edges( "reduce_middle_step", lambda state: ( END if state["current_step"] >= state["total_number_of_steps"] else "A" ), ) main_graph = g.compile(checkpointer=MemorySaver(), interrupt_after=["B"]) with open("./main_graph.png", "wb") as f: f.write(main_graph.get_graph().draw_mermaid_png()) ``` ### Error Message and Stack Trace (if applicable) ```shell The graph diagram has unspecified connections ``` ### Description Run the code and check the image generated. It has conditional edges from "recude_middle_step" to "entry", "A", and "B" where I only connected to "A". ![main_graph](https://github.com/user-attachments/assets/f1d046e7-bd4d-4246-b8d3-11a8084922e3) ### System Info not required.
yindo closed this issue 2026-02-20 17:31:13 -05:00
Author
Owner

@gbaian10 commented on GitHub (Aug 19, 2024):

You can refer to the reply of this issue:


Or check the description in the docstring.

image

@gbaian10 commented on GitHub (Aug 19, 2024): You can refer to the reply of this issue: - #987. --- Or check the description in the docstring. ![image](https://github.com/user-attachments/assets/4ff0560e-af90-4f1a-af32-9d21c26e4901)
Author
Owner

@minki-j commented on GitHub (Aug 20, 2024):

Thank you @gbaian10 !!

@minki-j commented on GitHub (Aug 20, 2024): Thank you @gbaian10 !!
Author
Owner

@hinthornw commented on GitHub (Aug 20, 2024):

Thanks a ton for all of your contributions to the discussions, @gbaian10 !

@hinthornw commented on GitHub (Aug 20, 2024): Thanks a ton for all of your contributions to the discussions, @gbaian10 !
Author
Owner

@vbarda commented on GitHub (Aug 20, 2024):

+1, thank you @gbaian10 ! we would also love to invite you to join LangChain Community on Slack if you're interested / haven't done it yet! https://www.langchain.com/join-community

@vbarda commented on GitHub (Aug 20, 2024): +1, thank you @gbaian10 ! we would also love to invite you to join LangChain Community on Slack if you're interested / haven't done it yet! https://www.langchain.com/join-community
Author
Owner

@gbaian10 commented on GitHub (Aug 20, 2024):

@vbarda Thank you, I have successfully joined. I never knew there was such a great place. 😳

@gbaian10 commented on GitHub (Aug 20, 2024): @vbarda Thank you, I have successfully joined. I never knew there was such a great place. 😳
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#198