Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Agents · Const

END

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.

How it works

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.

Syntax

import { END } from "@langchain/langgraph";

Returns

A graph destination representing terminal execution; it does not run another node after the incoming edge.

Key points

  • END marks a terminal node in the graph.
  • An edge targeting END means there are no actions after that edge completes.
  • Conditional edges are the usual way to route into END based on a termination condition.
  • A loop can stop by routing to END once its termination condition is reached.

Common mistakes

  • Graphs containing loops need an explicit termination mechanism; otherwise, execution cannot finish.

Example: Terminate a graph with END

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.

When to use it

Finish a workflow

A workflow reaches a successful or failed terminal state.

Terminate a loop

A graph repeatedly processes state until a runtime condition is satisfied.

Conditional routing

A router chooses whether to continue processing or stop.

Interview questions

QWhat does END represent?

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.

QHow is END commonly used with loops?

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.

QHow do you reference END in LangGraph.js?

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.

  • START
  • StateGraph
  • conditional edges
  • compile
  • addConditionalEdges

Source: Graph API overview. Checked 2026-10-15.