{ "cells": [ { "cell_type": "markdown", "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ "# How to view and update graph state\n", "\n", "Once you start [checkpointing](./persistence.ipynb) your graphs, you can easily **get** or **update** the state of the agent at any point in time. This permits a few things:\n", "\n", "1. You can surface a state during an interrupt to a user to let them accept an action.\n", "2. You can **rewind** the graph to reproduce or avoid issues.\n", "3. You can **modify** the state to embed your agent into a larger system, or to let the user better control its actions.\n", "\n", "The key methods used for this functionality are:\n", "\n", "- [get_state](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.graph.CompiledGraph.get_state): fetch the values from the target config\n", "- [update_state](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.graph.CompiledGraph.update_state): apply the given values to the target state\n", "\n", "**Note:** this requires passing in a checkpointer.\n", "\n", "Below is a quick example.\n", "\n", "
Note:
\n", "\n",
" In this how-to, we will create our agent from scratch to be transparent (but verbose). You can accomplish similar functionality using the create_react_agent(model, tools=tool, checkpointer=checkpointer) (API doc) constructor. This may be more appropriate if you are used to LangChain’s AgentExecutor class.\n",
"