This document describes the memory management systems that enable AI agents to retain and recall information across sessions. Agent memory systems provide the foundation for self-improving agents that learn from past interactions and maintain user preferences over time.
For information about managing context within a single session, see Context Engineering. For details on communication protocols between agents, see Agentic Protocols.
Agent memory systems address the stateless nature of Large Language Models by implementing persistent storage and retrieval mechanisms. This document covers:
Sources: 13-agent-memory/README.md1-164 13-agent-memory/13-agent-memory-cognee.ipynb1-50
Agent memory is categorized into six distinct types, each serving a specific purpose in the agent's operation:
| Memory Type | Persistence | Purpose | Example Use Case |
|---|---|---|---|
| Working Memory | Single task | Immediate computation context | Current travel booking parameters 13-agent-memory/README.md64-67 |
| Short-term Memory | Single session | Conversation context | References within current dialogue 13-agent-memory/README.md74-77 |
| Long-term Memory | Cross-session | User preferences and history | Past trip preferences, injury avoidance 13-agent-memory/README.md82-84 |
| Persona Memory | Persistent | Agent role and personality | "Expert ski planner" identity 13-agent-memory/README.md90-91 |
| Episodic Memory | Persistent | Task execution history | Failed booking attempts, learned patterns 13-agent-memory/README.md97-99 |
| Entity Memory | Persistent | Extracted entities and events | Places visited, restaurants recommended 13-agent-memory/README.md105-107 |
Working memory functions as a scratch space for the agent's current reasoning process. In implementation, this manifests as the most relevant information extracted from conversation history, focusing on requirements, proposals, decisions, and actions currently under consideration.
Diagram: Working Memory Flow
Sources: 13-agent-memory/README.md58-68
Short-term memory retains information for the duration of a single conversation session. In the Microsoft Agent Framework, this maps to AgentSession, created via agent.create_session(). This context is kept available while the session is reused but is not persisted when the application restarts.
Sources: 13-agent-memory/README.md68-73
Long-term memory persists information across multiple sessions. This is important for personalization and is typically achieved through a database, vector index, or persistent store like Azure AI Search.
Sources: 13-agent-memory/README.md78-84
Two primary frameworks provide specialized memory capabilities: Mem0 and Cognee.
Mem0 implements a two-phase memory pipeline that transforms conversations into structured memories.
Diagram: Mem0 Memory Pipeline
Sources: 13-agent-memory/README.md122-128
Cognee provides a semantic memory system that transforms unstructured data into queryable knowledge graphs backed by embeddings.
Diagram: Cognee Dual-Store Architecture
Cognee supports multiple search strategies including raw chunk lookup, vector similarity, and graph-aware traversal.
Sources: 13-agent-memory/README.md129-148 13-agent-memory/13-agent-memory-cognee.ipynb99-148
Redis provides the caching infrastructure for session-based memory in Cognee. This enables context retention across conversation turns.
Diagram: Redis Session Cache Architecture
Key implementation details:
CACHING=true environment variable 13-agent-memory/13-agent-memory-cognee.ipynb68-70get_cache_engine() 13-agent-memory/13-agent-memory-cognee.ipynb621-625last_n parameter 13-agent-memory/13-agent-memory-cognee.ipynb634-639Sources: 13-agent-memory/13-agent-memory-cognee.ipynb621-678
Cognee's cognify() function processes raw data into structured knowledge graphs.
cognee.add(text, node_set=["category"]) ingests text.cognee.cognify() extracts entities and creates relationships.cognee.memify() analyzes patterns to generate rules.Sources: 13-agent-memory/13-agent-memory-cognee.ipynb484-549
Cognee's search system enables agents to query across multiple memory sources simultaneously using SearchType.GRAPH_COMPLETION.
Diagram: Multi-Source Memory Retrieval
Sources: 13-agent-memory/13-agent-memory-cognee.ipynb574-600 13-agent-memory/13-agent-memory-cognee.ipynb687-747
The self-improving agent pattern uses a dedicated knowledge agent to observe conversations and extract information for future use.
Diagram: Self-Improving Agent Architecture
This pattern allows the agent to:
Sources: 13-agent-memory/README.md144-162
Refresh this wiki