START and END
Entry and exit.
Start and end are two special nodes. Start is where the input enters the graph. End is where a run finishes. You never write functions for them. You just connect edges to them.

- Two special nodes
- START: input enters
- END: run finishes
Forgetting the start
What if we forget the edge from start? Here, we add a node, and an edge to the end, but nothing from start. Compile checks the graph, and raises an error. Run it. The message tells us exactly what's missing. The graph needs an entry point.
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
class State(TypedDict):
text: str
def shout(state):
return {"text": state["text"].upper()}
builder = StateGraph(State)
builder.add_node(shout)
builder.add_edge("shout", END) # no edge from START!
try:
builder.compile()
except ValueError as error:
print("Compile failed:", error)Compile failed: Graph must have an entrypoint: add at least one edge from START to another node
Start and end
Start must connect to at least one node. A run finishes when it reaches end. A graph can have several paths into end, and as we'll see, even several nodes after start, running in parallel.
| key | value |
|---|---|
| START | needs an edge |
| END | finishes a run |
| Many paths | can reach END |
| Compile | checks for mistakes |
Summary
Start is where input enters, and end is where a run finishes. Compile catches a missing start. Next, compiling and invoking in more detail.
Key takeaways- START
- END
- Compile checks