7. Memory Systems
Long-running agents face a variant of the context rot problem: session history grows until it exceeds the context window, or until early context is effectively ignored. Memory systems solve this by moving information out of the context window and into persistent storage, retrieving it on demand.
Short-Term: Compaction and Structured Note-Taking
For Claude Code specifically, two mechanisms handle session-level memory:
/compact summarizes the conversation history, replacing the raw exchange with a dense summary. The model retains continuity but the token count resets substantially. Use at 70% context usage, not 90%.
Structured note-taking via hooks is the agentic version: a PostToolUse hook writes key decisions, discovered facts, and task state to a notes file. The agent loads this file at the start of the next session. This sidesteps context rot entirely for multi-session work: the notes file sits at the start of the context (maximum attention) and contains only curated information.
Auto Memory (v2.1.59+) and Auto Dream provide native CC alternatives: Claude writes its own MEMORY.md between sessions, and a background sub-agent consolidates it after ≥5 sessions and ≥24 hours. See Memory Systems: Auto Memory.
Long-Term: External Memory Systems
For multi-session and multi-agent workflows, persistent memory systems store information outside the context window and retrieve it selectively. The CC ecosystem has a three-tier model:
Individual (no team): claude-mem (89K stars, hooks-based auto-capture), agentmemory (26K stars, BM25+vector+graph fusion, 95.2% R@5), ICM (Rust binary, dual decay+graph architecture, brew install icm). Stars verified 2026-07-27.
Team sharing: CLAUDE.md + .mcp.json + skills committed to the repo (the Trinity, zero infra). Mem0 Cloud MCP for pooled team memory. Zep/Graphiti for temporal knowledge graphs. On making this shared context hold up across a whole team rather than a single session, see context engineering for the team, not just the session.
The RAG-vs-Memory distinction: RAG is the model's access to external world knowledge (docs, codebase, web). Memory is its access to user-specific and session-specific knowledge (preferences, past decisions, continuity). Both are retrieval systems serving different parts of the information architecture. A well-designed agent uses both.
Canonical reference: Memory Systems guide: 20-tool comparison table, architecture patterns, risk matrix, decision flowchart, and benchmarks.