Advanced
memoryagentsknowledge-graphvector-dbcognitive

Tripartite Cognitive Memory

An agent that forgets everything between sessions is frustrating. An agent that stuffs all its history into every prompt is slow and expensive. This pattern gives agents three separate memory systems so they remember the right things without loading everything.

Used in
Tripartite Cognitive Memory
Mini Map
Pan, zoom, and explore. Click export to download as PNG.

Interactive diagram — pan, zoom, and explore. Click export to download as PNG.

📐Why one memory store is not enough — and why context stuffing fails

Three types of memory, three different problems

Think about how you remember things. You remember the specific conversation you had with a colleague yesterday — that is episodic memory, tied to a specific event in time. You know general facts about your field that you have built up over years — that is semantic memory, stable knowledge about how things work. You know how to type without thinking about which keys to press — that is procedural memory, learned skills and behaviors that run automatically.

AI agents need the same separation. Without external memory, agents are amnesiac — each conversation starts from scratch, with no knowledge of what happened before. The instinctive fix is to dump everything into the prompt: the last 100 interactions, all the established facts, all the user preferences. That approach is expensive (long contexts cost more to process), slow (reasoning quality degrades as context grows), and fragile (relevant memories get diluted by irrelevant ones).

Tripartite memory solves this by building three separate stores for three types of information, each updated and queried differently. When a question arrives, the agent retrieves only what is relevant from each store — a small, targeted set of memories rather than a full history dump. Over time, a consolidation process promotes the most important episodic events into the semantic store, similar to how human sleep consolidates short-term into long-term memory.

Next up:Episodic Memory
🔧A timestamped record of what happened

Episodic Memory

Episodic memory records specific events in order. Every interaction, every action the agent took, every response it gave, every outcome — timestamped and stored. When the agent needs to recall something specific — "what did this user ask for last week?", "what happened the last time I ran this type of task?" — it queries episodic memory using a combination of semantic similarity and time filters to find the most relevant past cases. Episodic memory changes the fastest of the three stores. New entries are written continuously during normal operation. Old entries are either pruned or promoted to semantic memory by the consolidation process over time. The storage format is typically a vector database with rich metadata (timestamps, session IDs, participant identifiers, outcome flags) that allows precise, targeted retrieval.

Episodic Memory
Mini Map
Pan, zoom, and explore. Click export to download as PNG.
📼

Event Log

A chronological record of what happened, who was involved, what was said or done, and what the outcome was. Structured enough to query precisely, rich enough to reconstruct what actually occurred.

🕒

Temporal Index

Metadata filtering by timestamp allows recency-biased retrieval without semantic search — "the five most recent interactions with this user" is a simple filter operation, not an embedding lookup.

👤

Actor Metadata

Each event is tagged with who caused it — the user, a specific agent, a tool call. This lets the agent reason about its own past behavior separately from user behavior.

🧩

Case-Based Retrieval

Uses the current situation as a search query to find similar past cases. "The last time I encountered a question phrased like this, approach X worked well" — retrieved by semantic similarity against the event log.

Next up:Semantic Memory
🔧Stable facts and relationships the agent has learned

Semantic Memory

Semantic memory is where the agent stores things it has learned to be generally true — not "this specific thing happened on this date," but "this user always prefers concise answers," or "these two products are in the same category," or "this API endpoint requires OAuth before being called." It is the agent's accumulated model of the world and the people it works with. The most natural data structure for this is a knowledge graph: entities as nodes (users, products, concepts, services), relationships between them as typed edges. A vector sidecar lets the agent do fuzzy lookups when it knows approximately what it is looking for but not the exact entity name. A consolidation process periodically reviews episodic memory and promotes stable, repeated patterns into the semantic graph as facts.

Semantic Memory
Mini Map
Pan, zoom, and explore. Click export to download as PNG.
🧬

Entity Nodes

Every important person, object, or concept the agent knows about is a node. Nodes have structured attributes — a user node might store name, timezone, communication preferences, and technical level.

🔗

Relationship Edges

Typed, directional connections between entities — "user A manages project B", "topic X is a subcategory of topic Y". These edges are what make multi-hop questions answerable without additional searches.

🔮

Vector Sidecar

A vector embedding of each node's description, stored alongside the graph. Used when the agent needs to find entities by approximate meaning — "find products similar to this description" — rather than by exact ID.

🔄

Consolidator

A background process that reviews episodic memory and promotes repeated observations into the semantic graph as facts. If the agent has noticed three times that a user rejects verbose answers, that pattern becomes a stored fact.

Next up:Procedural Memory
🔧Learned skills and behaviors the agent updates itself

Procedural Memory

Procedural memory is the agent's collection of learned behaviors — not facts about the world, but knowledge of how to do things well. This includes successful tool-use sequences, effective prompt templates for specific task types, and strategies the agent has refined from its own trial and error. The distinctive feature of procedural memory is that the agent can modify it based on experience. When it discovers a better approach to a class of problem, it updates its skill library. When a strategy consistently fails, it marks it as unreliable. This is what enables an agent to genuinely improve over time rather than making the same mistake in every session.

Procedural Memory
Mini Map
Pan, zoom, and explore. Click export to download as PNG.
⚙️

Skill Manifest

A catalog of named procedures the agent can invoke — each with a description of when it applies, what inputs it takes, and what it produces. The agent searches this manifest the same way it searches other memory stores.

📜

Prompt Blocks

Versioned segments of the agent's system prompt that encode specific behaviors. The agent can edit these blocks based on what has worked, creating a feedback loop between past experience and future behavior.

🧪

Skill Distiller

A process that reviews successful episodic sequences and abstracts them into reusable procedures. Turns "this specific sequence of tool calls worked for this task" into "here is a reusable procedure for this class of task."

🛡️

Regression Guard

Monitors for cases where a self-edited prompt block makes the agent perform worse on tasks it previously handled well. Rolls back changes that cause silent regressions before they affect users.

Next up:When to Use This Pattern
🎯Signs this is the right architecture for your situation

When to Use This Pattern

Assistants or copilots that span many sessions with the same user and need to carry context across them
Agents that should learn from their own past mistakes rather than repeat them in every session
User-facing systems where learning preferences and adapting behavior over time is core to the experience
Any system where loading full conversation history into every prompt is too expensive or degrades answer quality
Next up:Trade-offs
⚖️What you gain — and what it costs

Trade-offs

Benefit
Cost
Selective retrieval can cut prompt token cost by up to 90% compared to stuffing full history
Requires running and maintaining a graph database, a vector database, and a key-value store together
Fast-changing episodic and stable semantic memory are updated and queried independently
Tuning the consolidation pipeline — when to promote, what to discard — requires careful experimentation
Procedural memory enables agents to genuinely improve their behavior over time
Agent-edited prompt blocks can regress silently — detecting regressions requires active monitoring
The three-store model maps naturally to how humans think about memory, making it intuitive to design around
Current LLMs are not reliably self-correcting — external memory alone does not fix reasoning failures