Skip to main content
Agent Memory doesn’t store everything forever in a flat list. Instead, it organizes your agent’s experience into four tiers of memory — each with a different lifespan, compression level, and retrieval role. Raw observations from today sit in working memory. Summaries of what happened last week live in episodic memory. The patterns your agent has learned across many sessions are distilled into semantic and procedural memory. This hierarchy means the right memories surface at the right time, without flooding your context window with irrelevant history.

The Four Tiers

Working memory holds the raw observations from your current and recent sessions. Every file read, every command, every error — all captured via hooks and stored immediately as RawObservation and then CompressedObservation records.
  • Lifespan: Current session and a rolling recent window
  • Content: Individual tool-use events, user prompts, agent responses, errors
  • Recency weight: Highest — working memory observations score strongly in retrieval for active projects
  • Analogy: Short-term memory — the scratchpad of what just happened
Working memory is the source of truth for real-time capture. Every other tier is derived from it through the consolidation pipeline.

The Consolidation Pipeline

Consolidation is the process that promotes observations from working memory through the higher tiers. It runs automatically at session end when you have an LLM provider configured.
Enable CONSOLIDATION_ENABLED=true in ~/.agentmemory/.env for the full pipeline. If you have an LLM provider key configured (ANTHROPIC_API_KEY, GEMINI_API_KEY, OPENAI_API_KEY, etc.), consolidation is on by default — you don’t need to set the flag explicitly. Disable it with CONSOLIDATION_ENABLED=false if you want fully LLM-free operation.
Without an LLM, the pipeline stops at the episodic tier — session summaries are generated using BM25-compatible synthetic compression, but semantic and procedural extraction require an LLM call. You can also trigger consolidation manually at any time using the memory_consolidate MCP tool or by calling POST /agentmemory/consolidate.

Memory Strength

Every memory in Agent Memory has a strength score. Strength is a composite of:
  • Recency — how recently the memory was created or last accessed
  • Access frequency — how many times the memory has been retrieved in search results
  • Reinforcement — whether the underlying fact has been confirmed by multiple independent sessions
Strong memories surface first in search results. Weak memories — old, rarely accessed, unconfirmed — gradually decay and eventually become candidates for eviction. This mirrors the Ebbinghaus forgetting curve: things you use stay sharp; things you don’t use fade.

Long-term vs Short-term Memory Objects

Agent Memory uses three distinct data structures depending on where in the lifecycle an observation lives: You interact primarily with Memory objects through the MCP tools and REST API. RawObservation and CompressedObservation records are accessible via memory_recall and the timeline view, but they’re mostly managed by Agent Memory internally.

Lessons

Lessons are a special memory type for high-confidence, explicitly learned insights. Unlike regular memories that are extracted automatically, lessons are created intentionally — either by the consolidation pipeline from a Crystal (a compact record of a completed action chain), manually via the memory_lesson_save MCP tool, or by the consolidation pass itself.
Lessons decay over time if not reinforced — if your agent never encounters the situation again, the lesson’s confidence gradually drops. When it is encountered and the lesson proves relevant, reinforcements increments and confidence rises. This keeps your lesson library current and removes lessons that no longer apply to your workflow. Control lesson decay with LESSON_DECAY_ENABLED=true (on by default).

Memory Slots

Memory slots are pinned memory units that persist across sessions and projects. Think of them as always-available context blocks that your agent can read and write — a persona slot, a user_preferences slot, project_context, pending_items, and more. Enable slots in ~/.agentmemory/.env:
With slots enabled, you get eight built-in slots: Slots are size-limited and pinned — they’re always injected at session start, regardless of the token budget. Manage them using the memory_slot_* MCP tools. Pair slots with AGENTMEMORY_REFLECT=true to enable automatic slot updates at session end: Agent Memory scans recent observations and auto-appends TODOs to pending_items, counts patterns in session_patterns, and records touched files in project_context.