Two distinct distinctions are used to define an agent's memory: which interactions can access the information and what type of information the memory holds. LangChain explains the first distinction in terms of short-term and long-term memory. CoALA divides long-term memory into episodic, semantic and procedural memory. In this classification, episodic memory is not an alternative duration category to long-term memory; it is a type of memory that holds past experiences.
Short-term memory: The state of a conversation
According to LangChain, short-term memory enables an agent to remember previous interactions within a thread or conversation. A thread organizes multiple interactions in a session together. This scope describes which conversation the memory is associated with.
LangGraph manages short-term memory as part of the agent's state. State is stored in thread-scoped checkpoints. A checkpointer saves state to a database, allowing the thread to be resumed later. Short-term memory is updated when the graph is invoked or a step is completed. State is read at the start of each step.
State does not have to consist only of message history. Alongside conversation history, LangChain gives uploaded files and generated outputs as examples of data that can be held in state. When this information is in graph state, the application can access the context of the relevant conversation while keeping different threads separate.
In the chat applications described by LangChain, messages alternate between user inputs and model responses. As these interactions continue, the message list grows. The context given to the chat model can also include a system message supplied by the developer and a human message sent by the user.
The concept of working memory in CoALA also focuses on information used in the current decision cycle. This memory can contain perceptual inputs, active information generated through reasoning or retrieved from long-term memory, and goals carried over from the previous decision cycle. CoALA does not limit working memory to the LLM's context; it treats it as a data structure that persists between LLM calls.
For each LLM call, the input is constructed from a portion of the working memory contents. CoALA gives a prompt template and the associated variables as an example. The model's output is parsed and written back to variables in working memory. These variables can include the name and arguments of an action, which are then used to execute the corresponding action.
Long-term memory: Information across sessions
In LangGraph, long-term memory holds information across different conversations or sessions. In contrast to the thread scope of short-term memory, long-term memory is stored in custom namespaces. LangChain states that this memory can contain user-specific or application-level data and can be shared across conversation threads. LangGraph stores provide functions for saving and retrieving this information.
CoALA's distinction considers the content of information as well as how long it is retained. Semantic memory holds the agent's knowledge about the world and itself. Episodic memory stores experiences from previous decision cycles. In CoALA, procedural memory covers knowledge embedded in model weights and knowledge explicitly written in the agent's code.
LangChain gives facts about a user as an example of semantic memory. This type of memory is not the same concept as semantic search. Semantic memory refers to the storage of facts and information. Semantic search is a method of retrieving similar content based on meaning rather than exact matches.
LangChain also describes storing semantic memory as a profile. Such a profile can contain selected information about a specific entity, such as a user, an organization or the agent itself. A profile is typically a JSON structure made up of key-value pairs that represent the domain. The previous profile can be given to the model to generate a new profile or a JSON patch to apply to the old structure. LangChain notes that this update can become error-prone as the profile grows.
The same information can also be held in a collection of separate memory records that are updated and expanded over time. According to LangChain, this approach also requires updating or deleting existing records and searching within the list. Some models may tend to add too many records to the list, while others may tend to update existing records too often. LangChain Store offers semantic search and filtering by content across a collection.