Missing conditional edge when displaying graph #4450
Unanswered
fabio-barbieri
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I am also experiencing the same issue. When I try to render the following graph using Mermaid, the arrow pointing from the "conversation" node to "END" is not displayed. My from IPython.display import Image, display
from langgraph.graph import StateGraph, START, END
from typing import Literal
from langgraph.graph import MessagesState
class State(MessagesState):
summary: str
def call_model(state: State):
response = "dummy response"
return {"messages": response}
def summarize_conversation(state: State):
return {"summary": "dummy summary", "messages": []}
# Determine whether to end or summarize the conversation
def should_continue(state: State) -> Literal["summarize_conversation", "__end__"]:
"""Return the next node to execute."""
messages = state["messages"]
# If there are more than six messages, then we summarize the conversation
if len(messages) > 6:
return "summarize_conversation"
# Otherwise we can just end
return END
# Define a new graph
workflow = StateGraph(State)
workflow.add_node("conversation", call_model)
workflow.add_node(summarize_conversation)
# Set the entrypoint as conversation
workflow.add_edge(START, "conversation")
workflow.add_conditional_edges("conversation", should_continue)
workflow.add_edge("summarize_conversation", END)
# Compile
graph = workflow.compile()
display(Image(graph.get_graph().draw_mermaid_png())) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I was trying to build a simple workflow in langgraph to gain familiarity with the framework. My problem basically is that I'm adding two conditional edges in my graph, but when displaying it, it presents only a single conditional edge, while the other is missing.
I'm working on Google Colaboratory at the moment, using version 0.3.34 of langgraph. I'm leaving the code down below:
Here's the graph that I get:

Trying to understand the problem, I noticed that if I substitute the edge from node "user_risk_level_acceptance" to END, with an edge that goes from "user_risk_level_acceptance" back to "user_profiling_agent" I get a consistent graph. So, in the code, substituting

builder.add_edge("user_risk_level_acceptance", END)
withbuilder.add_edge("user_risk_level_acceptance", "user_profiling_agent")
, I get the expected graph, as shown below:Have I missed something in the first version of the code? Any help or clarification will be really appreciated! Thanks!
Beta Was this translation helpful? Give feedback.
All reactions