State
The shared notebook.
Think of state as a shared notebook. Every node can read it, and write to it. When one node finishes, the next node sees what it wrote. That's how information flows through a graph.

- A shared notebook
- Every node reads it
- And writes to it
Describing the state
We describe the state with a typed dictionary. Each key has a name and a type. Here, an order has a title, a quantity, a price, and a total. The node reads three keys, and writes the total. Run it. The final state holds everything, including the new total.
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
class Order(TypedDict):
title: str
quantity: int
price: float
total: float
def add_total(state: Order):
return {"total": round(state["quantity"] * state["price"], 2)}
builder = StateGraph(Order)
builder.add_node("add_total", add_total)
builder.add_edge(START, "add_total")
builder.add_edge("add_total", END)
graph = builder.compile()
print(graph.invoke({"title": "Dune", "quantity": 2, "price": 9.99})){'title': 'Dune', 'quantity': 2, 'price': 9.99, 'total': 19.98}Good state
Keep state small, and give every key a clear name. Store facts, not long explanations. Each key should have one job. And remember, any node can read any key, so the state is the contract between your nodes.
| key | value |
|---|---|
| Small | only what's needed |
| Clear names | one job each |
| Typed | TypedDict |
| Contract | between nodes |
Summary
State is a typed dictionary every node can read and update. It carries information through the graph. Next, nodes.
Key takeaways- TypedDict
- Keys and types
- Shared by all nodes