agentsclimarketplace

Memory systems

Skill viktorbezdek/skillstack/memory-systems/skills/memory-systems

Skills I use and develop to deliver better outcomes faster and with less effort.

Install
npx -y skills add viktorbezdek/skillstack --skill memory-systems

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 10 stars10 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Guides implementation of agent memory systems, compares production frameworks (Mem0, Zep/Graphiti, Letta, LangMem, Cognee), and designs persistence architectures for cross-session knowledge retention. Use when the user asks to "implement agent memory", "persist state across sessions", "build knowledge graph for agents", "track entities over time", "add long-term memory", "choose a memory framework", or mentions temporal knowledge graphs, vector stores, entity memory, adaptive memory, dynamic memory, or memory benchmarks (LoCoMo, LongMemEval). NOT for multi-agent coordination or agent handoffs (use multi-agent-patterns), NOT for tool design or tool interfaces (use tool-design), NOT for hosted agent infrastructure or sandboxed VMs (use hosted-agents).

SKILL.md

14.8 KB, as published. Nobody here has run it

Memory System Design

Memory provides the persistence layer that allows agents to maintain continuity across sessions and reason over accumulated knowledge. Simple agents rely entirely on context for memory, losing all state when sessions end. Sophisticated agents implement layered memory architectures that balance immediate context needs with long-term knowledge retention. The evolution from vector stores to knowledge graphs to temporal knowledge graphs represents increasing investment in structured memory for improved retrieval and reasoning.

When to Use

  • Building agents that must persist knowledge across sessions
  • Choosing between memory frameworks (Mem0, Zep/Graphiti, Letta, LangMem, Cognee)
  • Needing to maintain entity consistency across conversations
  • Implementing reasoning over accumulated knowledge
  • Designing memory architectures that scale in production
  • Evaluating memory systems against benchmarks (LoCoMo, LongMemEval, DMR)
  • Building dynamic memory with automatic entity/relationship extraction and self-improving (Cognee)

When NOT to Use

  • Coordinating multiple agents or agent handoffs (use multi-agent-patterns)
  • Designing individual tools or tool interfaces (use tool-design)
  • Setting up hosted agent infrastructure or sandboxed VMs (use hosted-agents)
  • General database design or data modeling (not specific to agent memory)
  • Caching strategies for API responses (that's application-level caching, not agent memory)

Decision Tree

What memory problem are you solving?
│
├─ Agent loses state between sessions
│  ├─ Simple facts/preferences? → File-system memory (JSON + timestamps)
│  ├─ Need semantic search? → Mem0 or vector store with metadata
│  ├─ Need entity tracking + relationships? → Zep/Graphiti (temporal KG)
│  └─ Need agent self-management of memory? → Letta or Cognee
│
├─ Choosing a framework
│  ├─ Fastest path to production? → Mem0 (managed infra, broad integrations)
│  ├─ Enterprise + temporal reasoning? → Zep/Graphiti (bi-temporal model)
│  ├─ Full agent introspection? → Letta (self-editing memory tiers)
│  ├─ Multi-hop reasoning + customizable pipeline? → Cognee (semantic graph)
│  └─ Already on LangGraph? → LangMem (tightest integration)
│
├─ Retrieval problems
│  ├─ Direct factual queries? → Semantic (embedding similarity)
│  ├─ "Tell me about X" queries? → Entity-based (graph traversal)
│  ├─ Facts change over time? → Temporal (validity filter)
│  └─ Best overall accuracy? → Hybrid (semantic + keyword + graph)
│
└─ Not sure if you need structured memory
   ├─ Single-session agent? → No, context window is enough
   ├─ Multi-session but simple facts? → File-system first, upgrade later
   └─ Complex reasoning across sessions? → Yes, start with Mem0, add graph when needed

Core Concepts

Memory spans a spectrum from volatile context window to persistent storage. Key insight from benchmarks: tool complexity matters less than reliable retrieval — Letta's filesystem agents scored 74% on LoCoMo using basic file operations, beating Mem0's specialized tools at 68.5%. Start simple, add structure (graphs, temporal validity) only when retrieval quality demands it.

Detailed Topics

Production Framework Landscape

FrameworkArchitectureBest ForTrade-off
Mem0Vector store + graph memory, pluggable backendsMulti-tenant systems, broad integrationsLess specialized for multi-agent
Zep/GraphitiTemporal knowledge graph, bi-temporal modelEnterprise requiring relationship modeling + temporal reasoningAdvanced features cloud-locked
LettaSelf-editing memory with tiered storage (in-context/core/archival)Full agent introspection, stateful servicesComplexity for simple use cases
CogneeMulti-layer semantic graph via customizable ECL pipeline with customizable TasksEvolving agent memory that adapts and learns; multi-hop reasoningHeavier ingest-time processing
LangMemMemory tools for LangGraph workflowsTeams already on LangGraphTightly coupled to LangGraph
File-systemPlain files with naming conventionsSimple agents, prototypingNo semantic search, no relationships

Zep's Graphiti engine builds a three-tier knowledge graph (episode, semantic entity, community subgraphs) with a bi-temporal model tracking both when events occurred and when they were ingested. Mem0 offers the fastest path to production with managed infrastructure. Letta provides the deepest agent control through its Agent Development Environment. Cognee produces multi-layer semantic graphs — it layers text chunks and entity types as nodes with detailed relationship edges, building interconnected knowledge engine. Every core piece (ingestion, entity extraction, post-processing, retrieval) is customizable.

Benchmark Performance Comparison

SystemDMR AccuracyLoCoMoHotPotQA (multi-hop)Latency
CogneeHighest on EM, F1, CorrectnessVariable
Zep (Temporal KG)94.8%Mid-range across metrics2.58s
Letta (filesystem)74.0%
Mem068.5%Lowest across metrics
MemGPT93.4%Variable
GraphRAG~75-85%Variable
Vector RAG baseline~60-70%Fast

Zep achieves up to 18.5% accuracy improvement on LongMemEval while reducing latency by 90%. Cognee outperformed Mem0, Graphiti, and LightRAG on HotPotQA multi-hop reasoning benchmarks across Exact Match, F1, and human-like correctness metrics. Letta's filesystem-based agents achieved 74% on LoCoMo using basic file operations, outperforming specialized memory tools — tool complexity matters less than reliable retrieval. No single benchmark is definitive; treat these as signals for specific retrieval dimensions rather than rankings.

Memory Layers (Decision Points)

LayerPersistenceImplementationWhen to Use
WorkingContext window onlyScratchpad in system promptAlways — optimize with attention-favored positions
Short-termSession-scopedFile-system, in-memory cacheIntermediate tool results, conversation state
Long-termCross-sessionKey-value store → graph DBUser preferences, domain knowledge, entity registries
EntityCross-sessionEntity registry + propertiesMaintaining identity ("John Doe" = same person across conversations)
Temporal KGCross-session + historyGraph with validity intervalsFacts that change over time, time-travel queries, preventing context clash

Retrieval Strategies

StrategyUse WhenLimitation
Semantic (embedding similarity)Direct factual queriesDegrades on multi-hop reasoning
Entity-based (graph traversal)"Tell me everything about X"Requires graph structure
Temporal (validity filter)Facts change over timeRequires validity metadata
Hybrid (semantic + keyword + graph)Best overall accuracyMost infrastructure

Zep's hybrid approach achieves 90% latency reduction (2.58s vs 28.9s) by retrieving only relevant subgraphs. Cognee implements hybrid retrieval through its 14 search modes — each mode combines different strategies from its three-store architecture (graph, vector, relational), letting agents select the retrieval strategy that fits the query type rather than using a one-size-fits-all approach.

Memory Consolidation

Consolidate periodically to prevent unbounded growth. Invalidate but don't discard — preserving history matters for temporal queries. Trigger on memory count thresholds, degraded retrieval quality, or scheduled intervals. See implementation reference for working consolidation code.

Anti-Patterns

Anti-PatternProblemSolution
Stuffing everything into contextLong inputs are expensive and degrade performanceUse just-in-time retrieval; load only relevant memories per prompt
Ignoring temporal validityOutdated facts poison context and cause contradictionsTrack valid_from/valid_until on every fact; prefer most recent valid_from on conflict
Over-engineering earlyComplex memory tooling before proving simpler approaches workStart with file-system memory; add sophistication only when retrieval fails
No consolidation strategyUnbounded memory growth degrades retrieval quality over timeSet memory count thresholds; consolidate on schedule; invalidate but don't discard
Treating all memories equallyNo priority or relevance ranking; noise drowns signalWeight by recency, frequency, and confidence; surface high-signal memories first
Skipping benchmark evaluationCannot tell if memory changes helped or hurtRun LoCoMo/LongMemEval before and after architecture changes
Blocking agent response on memory writesWrite latency adds to user-facing response timeQueue writes for async processing; never block the agent on a memory write
Ignoring privacy implicationsPersistent memory retains sensitive data indefinitelyImplement retention policies, deletion rights, and user-level memory controls

Practical Guidance

Choosing a Memory Architecture

Start simple, add complexity only when retrieval fails. Most agents don't need a temporal knowledge graph on day one.

  1. Prototype: File-system memory. Store facts as structured JSON with timestamps. Good enough to validate agent behavior.
  2. Scale: Move to Mem0 or vector store with metadata when you need semantic search and multi-tenant isolation.
  3. Complex reasoning: Add Zep/Graphiti when you need relationship traversal, temporal validity, or cross-session synthesis. Graphiti uses structured ties with generic relations, keeping graphs simple and easy to reason about; Cognee builds denser multi-layer semantic graphs with detailed relationship edges — choose based on whether you need temporal bi-modeling (Graphiti) or richer interconnected knowledge structures (Cognee).
  4. Full control: Use Letta or Cognee when you need agent self-management of memory with deep introspection.

Integration with Context

Memories must integrate with context systems to be useful. Use just-in-time memory loading to retrieve relevant memories when needed. Use strategic injection to place memories in attention-favored positions (beginning/end of context).

Error Recovery

  • Empty retrieval: Fall back to broader search (remove entity filter, widen time range). If still empty, prompt user for clarification.
  • Stale results: Check valid_until timestamps. If most results are expired, trigger consolidation before retrying.
  • Conflicting facts: Prefer the fact with the most recent valid_from. Surface the conflict to the user if confidence is low.
  • Storage failure: Queue writes for retry. Never block the agent's response on a memory write.

Examples

Example 1: Mem0 Integration

from mem0 import Memory

m = Memory()
m.add("User prefers dark mode and Python 3.12", user_id="alice")
m.add("User switched to light mode", user_id="alice")

# Retrieves current preference (light mode), not outdated one
results = m.search("What theme does the user prefer?", user_id="alice")

Example 2: Temporal Query

# Track entity with validity periods
graph.create_temporal_relationship(
    source_id=user_node,
    rel_type="LIVES_AT",
    target_id=address_node,
    valid_from=datetime(2024, 1, 15),
    valid_until=datetime(2024, 9, 1),  # moved out
)

# Query: Where did user live on March 1, 2024?
results = graph.query_at_time(
    {"type": "LIVES_AT", "source_label": "User"},
    query_time=datetime(2024, 3, 1)
)

Example 3: Cognee Memory Ingestion and Search

import cognee
from cognee.modules.search.types import SearchType

# Ingest and build knowledge graph
await cognee.add("./docs/")
await cognee.add("any data")
await cognee.cognify()

# Enrich memory 
await cognee.memify()

# Agent retrieves relationship-aware context
results = await cognee.search(
    query_text="Any query for your memory",
    query_type=SearchType.GRAPH_COMPLETION,
)

Guidelines

  1. Start with file-system memory; add complexity only when retrieval quality demands it
  2. Track temporal validity for any fact that can change over time
  3. Use hybrid retrieval (semantic + keyword + graph) for best accuracy
  4. Consolidate memories periodically — invalidate but don't discard
  5. Design for retrieval failure: always have a fallback when memory lookup returns nothing
  6. Consider privacy implications of persistent memory (retention policies, deletion rights)
  7. Benchmark your memory system against LoCoMo or LongMemEval before and after changes
  8. Monitor memory growth and retrieval latency in production

Integration

This skill builds on context-fundamentals. It connects to:

  • multi-agent-patterns - Shared memory across agents
  • context-optimization - Memory-based context loading
  • evaluation - Evaluating memory quality

References

Internal references:

Related skills in this collection:

  • context-fundamentals - Context basics
  • multi-agent-patterns - Cross-agent memory

External resources:

  • Zep temporal knowledge graph paper (arXiv:2501.13956)
  • Mem0 production architecture paper (arXiv:2504.19413)
  • Cognee optimized knowledge graph + LLM reasoning paper (arXiv:2505.24478)
  • LoCoMo benchmark (Snap Research)
  • MemBench evaluation framework (ACL 2025)
  • Graphiti open-source temporal KG engine (github.com/getzep/graphiti)
  • Cognee open-source knowledge graph memory (github.com/topoteretes/cognee)
  • Cognee comparison: Form vs Function — graph structure comparison and HotPotQA benchmarks across Mem0, Graphiti, LightRAG, Cognee

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.