Finish a workflow
A workflow reaches a successful or failed terminal state.
AI Agents · Const
END is LangGraph.js’s terminal graph node. Route an edge—typically a conditional edge—to END when execution should stop and no further node should run.
END is a special terminal node in LangGraph.js. Use it as the destination of an edge—commonly a conditional edge—to indicate that execution has no further actions after the selected node completes.
import { END } from "@langchain/langgraph";A graph destination representing terminal execution; it does not run another node after the incoming edge.
import { END, START, StateGraph } from "@langchain/langgraph";
import { Annotation } from "@langchain/langgraph";
const State = Annotation.Root({ done: Annotation<boolean>() });
const graph = new StateGraph(State)
.addNode("check", () => ({ done: true }))
.addEdge(START, "check")
.addConditionalEdges("check", (state) => state.done ? END : "check")
.compile();
await graph.invoke({ done: false });The graph routes from the check node to END when the state indicates completion.
A workflow reaches a successful or failed terminal state.
A graph repeatedly processes state until a runtime condition is satisfied.
A router chooses whether to continue processing or stop.
END is a special node representing a terminal point in the graph. An edge to END tells LangGraph that no actions follow the completed node.
Follow-up: How would a loop terminate conditionally? Add a conditional edge whose router returns END when the termination condition is met; otherwise return the next node name.
Use END as the return value from a conditional-edge router when the graph should stop. This is especially useful for loops, where the router decides between continuing to another node and terminating.
Follow-up: Why use a conditional edge rather than an unconditional edge? Because the destination depends on runtime state, allowing the same node to either continue processing or finish.
Import END from @langchain/langgraph and use it in the graph's edge definitions. The JavaScript documentation shows it alongside START and StateGraph in a graph-building example.
Follow-up: What is the relationship between START and END? START identifies the graph's entry edge, while END identifies a terminal destination.
STARTStateGraphconditional edgescompileaddConditionalEdges