Skip to content

States and Schemas

Sudhanshu edited this page Nov 11, 2026 · 1 revision

State Schemas and Validation

TypedDict routing

NumberState declares num: int, with optional num_type and output. Check_Node writes num_type; conditional routing uses that field to select Even_Node or Odd_Node.

Pydantic

GraphState restricts input and output to 1–10. calc_square builds and validates a new Pydantic state before returning an output update. Input 15 fails immediately; input 8 produces squared output 64, which fails the explicit validation inside the node. This nuance matters: not every partial node update is automatically validated as a complete output model.

Separate and private channels

input_output_schemas uses distinct InputState, GlobalState, OutputState; the final returned state contains only output fields. private_schema uses a PrivateState for character and word counts computed between nodes.

Relationship to reducers

A graph state is not just a global mutable Python dict; each node provides partial updates. See Reducers and Messages.

Clone this wiki locally