LangGraph 1 · Building graphs
Branch with a conditional edge
Pick the next node with a function that returns the name of a node or END.
def route(state: State):
return "tools" if state["messages"][-1].tool_calls else END
builder.add_conditional_edges("chatbot", route)
Official LangGraph 1 documentation