Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 16 of 37

Memory types

0 of 37 complete

Why it matters

A single vector store labelled memory hides a design problem: a past event, a stable fact and a learned procedure need different write rules, lifetimes and retrieval. Splitting by type lets you say that facts can be corrected, events are immutable, and procedures are versioned with the code. That separation is what makes deletion, audit and debugging tractable.

Mental model

Memory types are a diary, an address book and a recipe box: different containers because the contents age differently. The metaphor breaks because real memory does not sort so cleanly; one sentence can be an event, a fact and a hint about procedure, so a record may need to be filed once and read for several purposes.

How it works

One record, three lanes, one retrieval gateInteractive

Keyed transitions

  1. Classify → Semantic: subject ∧ value ∧ source ∧ window
  2. Episodic → Route: recent
  3. Route → In prompt: intent matched
  4. Semantic → Two current: edit in place
transitionfailurerepeat

Event · step 1 of 9

Turn ends

Entry: a working context holding six turns. Nothing is durable yet; the candidates are still sentences inside the context, and the store has six current facts and twelve episodes.

In state

  • Turn

Next: Classify by question

Episodes
12
Current facts
1
Superseded
0
Step 1/9 · Turn ends

Figure. Nine states. Classify sends a record down exactly one lane, and each lane has its own write guard and lifetime: events append, facts supersede, procedures carry a version. Route reads across lanes by intent. The two red states are the failures the page warns about: an event returned as a fact, and a fact edited in place so two values are current.

What to notice. The event count, the 210-token injection and the 180-day validity window are illustrative. Working context is the start state, not a fourth store. Procedure drift is drawn as the version guard on the procedure lane rather than as a state, and deletion is one rule per lane with a shared exit, which the prose covers and the figure omits to keep the board readable.

Text version

A state machine with nine states. Turn is the start, a pill. Turn goes to Classify, a hexagonal decision, on a candidate record. Classify sends an event to Episodic, a checkpoint; a fact to Semantic, a decision; and a procedure to Procedural, a checkpoint. Episodic goes to Route on recent, Semantic goes to Route on current, and Procedural goes to Route on how-to. Route goes to In prompt, a terminal pill, on intent matched, and to Type confused, a red failure box, on no type filter. Semantic goes to Two current, a red failure box, on edit in place. In prompt has a repeat edge back to Turn labelled next turn. The trace walks Turn, Classify, Episodic, Semantic, Procedural, Route, In prompt, then Type confused, then Two current. Counters show episodic rows rising from 12 to 13, current facts at 1 until the last step shows 2, and superseded rising from 0 to 1 then back to 0.

  1. Define the types the product needs and the question each answers at read time.
  2. For episodic records, store the step or turn id, timestamp and actor, and never rewrite history.
  3. For semantic facts, store a subject, a value, a source and a validity window, and supersede rather than edit.
  4. For procedural knowledge, keep prompts, code or versioned playbooks rather than free-text memory.
  5. Route retrieval by intent: recent events for continuity, facts for constraints, procedures for how-to.
  6. Apply one deletion policy per type, with events expiring sooner than stable facts.

Trade-offs

ChoiceGood forCostFails when
Single vector storeOne integration, simple retrievalMixed relevance and retention rulesTypes have different lifetimes or privacy needs
Typed storesCorrect retrieval and deletion per typeMore plumbing and schema workThe product is small and continuity is minimal
Append-only eventsAuditable and safe to replayGrowth and noise over timeQueries need the current value only
Mutable fact storeCompact and currentLoses history and provenanceA decision must be explained later
Trade-off mapInteractive

Good for

One integration, simple retrieval

Cost

Mixed relevance and retention rules

Fails when

Types have different lifetimes or privacy needs

  1. Types have different lifetimes or privacy needs
  2. The product is small and continuity is minimal
  3. Queries need the current value only
  4. A decision must be explained later

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: Single vector store is good for One integration, simple retrieval, costs Mixed relevance and retention rules, and fails when Types have different lifetimes or privacy needs. Typed stores is good for Correct retrieval and deletion per type, costs More plumbing and schema work, and fails when The product is small and continuity is minimal. Append-only events is good for Auditable and safe to replay, costs Growth and noise over time, and fails when Queries need the current value only. Mutable fact store is good for Compact and current, costs Loses history and provenance, and fails when A decision must be explained later

Failure modes

  • Type confusion. A one-off event is retrieved as a stable preference and the agent overfits. Debug: sample retrieved records and check each carries a type and a validity rule.
  • Immutable fact. A corrected fact cannot replace the old one and answers alternate. Debug: query by subject and assert exactly one current record.
  • Procedure in free text. A learned procedure drifts from the code that actually runs. Debug: diff stored procedures against the deployed prompt or playbook version.

In production

Monitor records per type, retrieval share per type and deletion lag. Cap episodic growth per user and test that deleting a user removes every type.

Common misconceptions

People think: Long-term memory is one database.

Actually: It is at least three lifetimes and write rules; one table can hold them but one policy cannot.

People think: More memory types make the agent smarter.

Actually: Each type adds a retrieval decision and a failure mode; add one when a question cannot be answered today.

Interview angle

Strong answers name the types, the question each answers, and the different write and delete rules, then explain how retrieval routes by intent. Weak answers say memory is a vector store of past conversations and never distinguish an event from a fact.

Sources