LangGraphLangGraph 1.2 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
38 small wins to finish your pathNext lesson →

State

The state is the one dictionary that travels between the nodes of a graph. Every node is handed it and returns the keys it wants to change.

Last updated: 29 Sep, 2026 · LangGraph 1.2

State: variables every node can read · from the Complete Agentic AI Course In 10 Hours · 173:56 to 177:26

The crash course explains state with the YouTube-to-blog workflow from its whiteboard. Each step is a node: a transcript generator, a title generator with an LLM and a prompt, and a content generator. The state holds variables that any node can read, here transcript, title and content. The first node saves the transcript, the title node reads it and saves the title, and the content node reads both. Carrying that context from node to node is why LangGraph's graph class, built in StateGraph, is called StateGraph.

The YouTube-to-blog workflow: __start__, transcript_generator, title_generator, content_generator and __end__ in a row, each reading and writing one State with transcript, title and content.

Before any graph, a node is only a function that takes a dictionary and returns a dictionary. The page starts smaller than the video's three-step workflow: one node that returns one new key is enough to see the rule.

A node reading and returning state

Example
def greet(state):
    return {"greeting": "Hello!"}

print(greet({}))

Why the argument is called state

greet takes one argument and returns a dictionary. In a graph that argument is the shared state, so the name says what it holds.

Describing the shape with TypedDict

python
from typing_extensions import TypedDict

class State(TypedDict):
    ticket: str
    category: str

A TypedDict says which keys the state has and their types. It is the recommended shape: plain dictionary typing, no runtime cost. LangGraph also accepts a Pydantic model when you want values validated as they come in, at some speed cost.

TypedDict vs Pydantic for state

TypedDictPydantic BaseModel
ValidationNone at runtimeValidates values on input
SpeedFastestSlower
Use whenMost graphsYou want bad input caught early

When you declare a state

  • Every graph declares a state; it is the first thing you write.
  • Anything one node must pass to another goes in the state.
Watch out. The state is your program's memory. If a node works something out and does not return it, it is gone when the function ends.
Try it yourself
  • Add a reply key to State.
  • Make greet return two keys and print the result.

You understood something today that you didn't yesterday.