- checks his bag (reads state),
- the map chooses the next road (transition),
- he performs the task (node logic),
- updates his bag (state mutation),
- and repeats until a finish point is reached.

- State: a dictionary-like object that carries inputs, outputs, and contextual variables through the graph.
- Node: a function that reads the state and returns an object with the keys it updates.
- Transition (edge): the directed connection between nodes that determines the next node to run.
- Entry / Finish points: the graph’s start and end nodes.
- Compile / Invoke: produce a runnable app from the graph and execute it with an initial state.

Minimal working StateGraph that answers a question
We’ll build a tiny single-node graph that takes a
question and writes an answer produced by an LLM.
State shape
Define the state using Python type hints to make shapes explicit and enable early type checks. Use TypedDict to declare expected keys and types.
Using
TypedDict makes your state shape explicit and helps catch type errors early during development.StateGraph with the QAState type, register the node, set entry and finish points, and compile the graph to a runnable app.
answer.
Scaling your graph
The same pattern — define a state, write nodes that read/update it, and connect nodes into a graph — scales to more advanced workflows:
- Branching and conditional transitions
- Loops and retries
- Persisted memory between runs
- Human-in-the-loop steps or approvals
- Observability and testing of individual nodes

- LangGraph (project docs / repo)
- OpenAI — https://openai.com
- Anthropic — https://www.anthropic.com
- LangChain — https://langchain.dev