Skip to content

StateGraph

StateGraph is the builder that holds a state schema, named nodes, and edges. It describes the workflow; compile() turns that description into something you can run.1

from typing_extensions import TypedDict
from langgraph.graph import StateGraph
class OrderState(TypedDict):
order_id: str
status: str
builder = StateGraph(OrderState)

Think of builder as a whiteboard. You still need to add work and routes.

Object Job
StateGraph(OrderState) Starts the definition
builder.add_node(...) Registers work
builder.add_edge(...) Registers routing
builder.compile() Produces the runnable graph

Creating StateGraph does not call a model, save state, or run anything. Do not confuse the builder with the compiled graph.

  1. LangChain, Graph API overview.