/pattern/episodic-memory/

04 · ProductionMemory ArchitectureExperience MemoryTask Episode StoreInteraction Memory

Episodic Memory.
Past tasks, persisted, so the agent can recognise its own déjà vu.

Completed interactions are stored as discrete, timestamped episodes — a natural-language memory stream — and retrieved later by a combined recency, importance, and relevance score, so the agent can reuse what worked in a similar past situation.

In practiceA software-debugging agent stores each resolved bug as an episode, then retrieves the three closest past episodes by embedding similarity when it encounters a new error.

When to reach for it

  • The agent needs to learn from past cases.
  • Recurring tasks follow similar solution paths.
  • Context including time, goal, and outcome is relevant.

When it backfires

  • Past cases quickly become obsolete.
  • Storing personal data is problematic.
  • A static semantic knowledge base suffices.

The tradeoff

Experience-based adaptation is gained against high curation and data privacy maintenance efforts.

The effect

What it actually does.

Past episodes are stored and retrieved by similarity.

log episodeepisodesrecall episode
Pitfalls

Two ways this pattern will hurt you.

Stale episodes mislead the planner

Episodes from a deprecated tool surface stay matchable. The planner picks an old strategy and runs it against an API that no longer exists.

Fix · Tag episodes with a tool-surface version. Filter or expire episodes when the surface they referenced changes.

Similarity alone retrieves the wrong episode

Ranking by embedding similarity only, a superficially-worded match outranks the genuinely relevant recent success, and the agent replays a strategy that never applied here.

Fix · Score retrieval by recency + importance + relevance combined (per Generative Agents), not similarity alone, and weight successful outcomes above mere textual match.

Framework support

Where Episodic Memory is native.

LangGraphstore + similarity recallNative
AutoGen / AG2teachability / memoryNative
Microsoft Agent Frameworkepisodic storeNative
CrewAIlong-term memoryNative

Search

Search patterns, frameworks, and pages.