This question often comes up in interviews for AI Engineer roles, especially for products that work with agentic systems. It's worth stressing right away that these conversations are usually not about implementation in specific frameworks, but about understanding the concept itself.
Short-term memory
Simply put, this is the context the system holds right now so it doesn't lose its train of thought: it remembers previous messages, steps already completed, and intermediate results within a single session.
It's important to understand that short-term memory is not used as a global context or a full-fledged knowledge layer. Its job is to support an isolated execution flow so the system can move forward consistently within a specific interaction.
A simple example is a coding assistant. If we create an agent in, say, Cursor, it will keep the context and dialogue history of the task we're trying to solve within that particular session. If we create a new agent or start a new session, it won't know about other conversations unless that context was explicitly saved separately.
Long-term memory
This is knowledge that the system retains across different sessions, so it doesn't have to start every new interaction from scratch. Unlike short-term memory, it isn't needed for the local execution flow. Instead, it acts as a knowledge layer that accumulates stable facts, user preferences, behavioral patterns, and other context that is valuable in future interactions.
If short-term memory is responsible for making sure the system doesn't lose its state right now, then long-term memory is responsible for making sure the system doesn't lose useful knowledge later.