Agent memory
We discussed memory mechanisms in Chapter 3. To recap, LangGraph has the notion of short-term memory via the Checkpointer
mechanism, which saves checkpoints to persistent storage. This is the so-called per-thread persistence (remember, we discussed earlier in this chapter that the notion of a thread in LangGraph is similar to a conversation). In other words, the agent remembers our interactions within a given session, but it starts from scratch each time.
As you can imagine, for complex agents, this memory mechanism might be inefficient for two reasons. First, you might lose important information about the user. Second, during the exploration phase when looking for a solution, an agent might learn something important about the environment that it forgets each time – and it doesn’t look efficient. That’s why there’s the concept of long-term memory, which helps an agent to accumulate knowledge and gain from historical experiences, and enables...