$npx -y skills add sickn33/agentic-awesome-skills --skill agent-memory-systemsMemory is the cornerstone of intelligent agents. Without it, every
| 1 | # Agent Memory Systems |
| 2 | |
| 3 | Memory is the cornerstone of intelligent agents. Without it, every interaction |
| 4 | starts from zero. This skill covers the architecture of agent memory: short-term |
| 5 | (context window), long-term (vector stores), and the cognitive architectures |
| 6 | that organize them. |
| 7 | |
| 8 | Key insight: Memory isn't just storage - it's retrieval. A million stored facts |
| 9 | mean nothing if you can't find the right one. Chunking, embedding, and retrieval |
| 10 | strategies determine whether your agent remembers or forgets. |
| 11 | |
| 12 | The field is fragmented with inconsistent terminology. We use the CoALA cognitive |
| 13 | architecture framework: semantic memory (facts), episodic memory (experiences), |
| 14 | and procedural memory (how-to knowledge). |
| 15 | |
| 16 | ## Principles |
| 17 | |
| 18 | - Memory quality = retrieval quality, not storage quantity |
| 19 | - Chunk for retrieval, not for storage |
| 20 | - Context isolation is the enemy of memory |
| 21 | - Right memory type for right information |
| 22 | - Decay old memories - not everything should be forever |
| 23 | - Test retrieval accuracy before production |
| 24 | - Background memory formation beats real-time |
| 25 | |
| 26 | ## Capabilities |
| 27 | |
| 28 | - agent-memory |
| 29 | - long-term-memory |
| 30 | - short-term-memory |
| 31 | - working-memory |
| 32 | - episodic-memory |
| 33 | - semantic-memory |
| 34 | - procedural-memory |
| 35 | - memory-retrieval |
| 36 | - memory-formation |
| 37 | - memory-decay |
| 38 | |
| 39 | ## Scope |
| 40 | |
| 41 | - vector-database-operations → data-engineer |
| 42 | - rag-pipeline-architecture → llm-architect |
| 43 | - embedding-model-selection → ml-engineer |
| 44 | - knowledge-graph-design → knowledge-engineer |
| 45 | |
| 46 | ## Tooling |
| 47 | |
| 48 | ### Memory_frameworks |
| 49 | |
| 50 | - LangMem (LangChain) - When: LangGraph agents with persistent memory Note: Semantic, episodic, procedural memory types |
| 51 | - MemGPT / Letta - When: Virtual context management, OS-style memory Note: Hierarchical memory tiers, automatic paging |
| 52 | - Mem0 - When: User memory layer for personalization Note: Designed for user preferences and history |
| 53 | |
| 54 | ### Vector_stores |
| 55 | |
| 56 | - Pinecone - When: Managed, enterprise-scale (billions of vectors) Note: Best query performance, highest cost |
| 57 | - Qdrant - When: Complex metadata filtering, open-source Note: Rust-based, excellent filtering |
| 58 | - Weaviate - When: Hybrid search, knowledge graph features Note: GraphQL interface, good for relationships |
| 59 | - ChromaDB - When: Prototyping, small/medium apps Note: Developer-friendly, ~20ms p50 at 100K vectors |
| 60 | - pgvector - When: Already using PostgreSQL, simpler setup Note: Good for <1M vectors, familiar tooling |
| 61 | |
| 62 | ### Embedding_models |
| 63 | |
| 64 | - OpenAI text-embedding-3-large - When: Best quality, 3072 dimensions Note: $0.13/1M tokens |
| 65 | - OpenAI text-embedding-3-small - When: Good balance, 1536 dimensions Note: $0.02/1M tokens, 5x cheaper |
| 66 | - nomic-embed-text-v1.5 - When: Open-source, local deployment Note: 768 dimensions, good quality |
| 67 | - all-MiniLM-L6-v2 - When: Lightweight, fast local embedding Note: 384 dimensions, lowest latency |
| 68 | |
| 69 | ## Patterns |
| 70 | |
| 71 | ### Memory Type Architecture |
| 72 | |
| 73 | Choosing the right memory type for different information |
| 74 | |
| 75 | **When to use**: Designing agent memory system |
| 76 | |
| 77 | # MEMORY TYPE ARCHITECTURE (CoALA Framework): |
| 78 | |
| 79 | """ |
| 80 | Three memory types for different purposes: |
| 81 | |
| 82 | 1. Semantic Memory: Facts and knowledge |
| 83 | - What you know about the world |
| 84 | - User preferences, domain knowledge |
| 85 | - Stored in profiles (structured) or collections (unstructured) |
| 86 | |
| 87 | 2. Episodic Memory: Experiences and events |
| 88 | - What happened (timestamped events) |
| 89 | - Past conversations, task outcomes |
| 90 | - Used for learning from experience |
| 91 | |
| 92 | 3. Procedural Memory: How to do things |
| 93 | - Rules, skills, workflows |
| 94 | - Often implemented as few-shot examples |
| 95 | - "How did I solve this before?" |
| 96 | """ |
| 97 | |
| 98 | ## LangMem Implementation |
| 99 | """ |
| 100 | from langmem import MemoryStore |
| 101 | from langgraph.graph import StateGraph |
| 102 | |
| 103 | # Initialize memory store |
| 104 | memory = MemoryStore( |
| 105 | connection_string=os.environ["POSTGRES_URL"] |
| 106 | ) |
| 107 | |
| 108 | # Semantic memory: user profile |
| 109 | await memory.semantic.upsert( |
| 110 | namespace="user_profile", |
| 111 | key=user_id, |
| 112 | content={ |
| 113 | "name": "Alice", |
| 114 | "preferences": ["dark mode", "concise responses"], |
| 115 | "expertise_level": "developer", |
| 116 | } |
| 117 | ) |
| 118 | |
| 119 | # Episodic memory: past interaction |
| 120 | await memory.episodic.add( |
| 121 | namespace="conversations", |
| 122 | content={ |
| 123 | "timestamp": datetime.now(), |
| 124 | "summary": "Helped debug authentication issue", |
| 125 | "outcome": "resolved", |
| 126 | "key_insights": ["Token expiry was root cause"], |
| 127 | }, |
| 128 | metadata={"user_id": user_id, "topic": "debugging"} |
| 129 | ) |
| 130 | |
| 131 | # Procedural memory: learned pattern |
| 132 | await memory.procedural.add( |
| 133 | namespace="skills", |
| 134 | content={ |
| 135 | "task_type": "debug_auth", |
| 136 | "steps": ["Check token expiry", "Verify refresh flow"], |
| 137 | "example_interaction": few_shot_example, |
| 138 | } |
| 139 | ) |
| 140 | """ |
| 141 | |
| 142 | ## Memory Retrie |