
Graph Lifecycle
The journey of a request through the graph.
Graph Lifecycle
Understanding the lifecycle of a single execution run is critical for debugging.
The Steps of Execution
graph TD
Input[Input Data] --> Init[Initialize State]
Init --> Entry[Entry Node]
Entry --> Exec{Execute Logic}
Exec --> Update[Update State]
Update --> Check{Check Edges}
Check -- "Next Node" --> Entry
Check -- "END" --> Terminate[Finish]
- Initialize: The graph receives input (e.g.,
{"messages": ["Hi"]}). This initializes the starting State. - Enter Entry Point: The graph identifies the first node.
- Execute Node: The function runs. It returns a state update (e.g.,
{"key": "new_value"}). - Update State: The runtime merges the update into the global state.
- Scan Edges: The runtime looks at outgoing edges from the current node.
- Transition: The system moves to the next node.
Persistence (Checkpoints)
If you configured a Checkpointer (like Postgres), LangGraph saves the State to the database after Step 4 (every state update). This means if the server crashes at Step 5, you can resume exactly where you left off.