Chat History Hits a Wall
Chat history works fine for a single conversation. The model sees everything you've said, everything it's said, and can reference any part of it. But it falls apart in at least three ways: it doesn't survive across sessions, it fills up the context window, and it stores everything with equal importance regardless of relevance.
For an AI agent that works on tasks spanning days or weeks, this is a problem. The agent needs to remember what it learned yesterday without replaying the entire conversation. It needs to recall that a particular API endpoint was flaky without searching through hundreds of messages to find that observation.
Working Memory vs Long-Term Memory
Human memory has distinct systems, and effective agent architectures mirror this. Working memory is what the agent is actively using right now: the current task, relevant context, recent observations. It's small and focused. Long-term memory is everything the agent has learned or experienced that might be useful later. It's large and searchable.
In practice, working memory maps to the current context window (with careful curation of what goes in it), while long-term memory maps to an external store, usually a vector database or structured knowledge base. The agent retrieves from long-term memory into working memory as needed, similar to how you recall relevant facts when working on a problem.
Types of Agent Memory
Episodic memory stores specific experiences: "Last time I tried to deploy to staging, the build failed because of a missing environment variable." This lets agents learn from their own history without someone explicitly teaching them. You can find MCP servers that connect agents to vector stores for this purpose.
Semantic memory stores general knowledge: "The production database is PostgreSQL 15, the staging database is PostgreSQL 14." This is factual information the agent needs to do its job correctly, independent of any specific episode.
Procedural memory stores how to do things: "To deploy the frontend, run these three commands in this order." This captures workflows and procedures that the agent can follow without figuring them out from scratch each time.
Implementation Patterns
The simplest implementation is a key-value store that the agent reads from at the start of each session and writes to at the end. More sophisticated approaches use vector embeddings for semantic search over memories, letting the agent find relevant past experiences based on similarity to the current situation.
Search for memory and vector store tools on Skillful.sh to see what's available in the ecosystem. The options range from simple file-based stores to full-featured memory management systems.