LangGraph · Lesson 109 of 120
Designing State
Keep it small.
Most messy graphs have messy state. Too many keys, unclear names, and data that's stored twice. A few simple rules keep state clean, and the whole graph easier to understand.

- Messy graphs, messy state
- Too many keys
- A few simple rules
State rules
Store facts, not things you can work out. A total can be calculated from the lines. Use clear names, like refund amount, not amt. Pick the right reducer for each key. And keep large data, like documents, out of the state, storing only IDs or summaries.
| key | value |
|---|---|
| Facts | not derived values |
| Names | clear, specific |
| Reducers | chosen per key |
| Large data | store IDs instead |
Messy vs clean
Here's a messy state, with vague names, duplicated data, and whole documents. And a clean one, with clear names, one place for each fact, and only the document IDs.
Messy
- data, data2, tmptotal AND linesfull documents
Clean
- refund_amount, categorylines onlydocument IDs
Summary
Good state stores facts, uses clear names, picks the right reducers, and keeps large data out. Next, designing the graph itself.
Key takeaways- Facts only
- Clear names
- Small state
Next up: Designing Graphs — small nodes