Example: using Postgres checkpointer
checkpointer.setup()
the first time you’re using Postgres checkpointerExample: using Postgres store
store.setup()
the first time you’re using Postgres storeInMemoryStore
is a store that stores data in memory. In a production setting, you would typically use a database or other persistent storage. Please review the store documentation for more options. If you’re deploying with LangGraph Platform, the platform will provide a production-ready store for you.put
method. Please see the BaseStore.put API reference for more details.users
namespace to group user data.get
method is used to retrieve data from the store. The first argument is the namespace, and the second argument is the key. This will return a StoreValue
object, which contains the value and metadata about the value.store
is passed to the agent. This enables the agent to access the store when running tools. You can also use the store from the config to access it from anywhere in your code.InMemoryStore
is a store that stores data in memory. In a production setting, you would typically use a database or other persistent storage. Please review the store documentation for more options. If you’re deploying with LangGraph Platform, the platform will provide a production-ready store for you.UserInfo
schema defines the structure of the user information. The LLM will use this to format the response according to the schema.saveUserInfo
function is a tool that allows an agent to update user information. This could be useful for a chat application where the user wants to update their profile information.put
method is used to store data in the store. The first argument is the namespace, and the second argument is the key. This will store the user information in the store.userId
is passed in the config. This is used to identify the user whose information is being updated.Long-term memory with semantic search
strategy
(e.g., keep the last maxTokens
) to use for handling the boundary.
stateModifier
with the trimMessages
function:Full example: trim messages
RemoveMessage
. For RemoveMessage
to work, you need to use a state key with messagesStateReducer
reducer, like MessagesZodState
.
To remove specific messages:
user
messageassistant
messages with tool calls to be followed by corresponding tool
result messages.Full example: delete messages
Full example: summarize messages