Memory Architecture

Short-term, long-term, retrieved.

Relevant conversation history, completed task episodes, and structured long-term knowledge are stored and retrieved to give agents persistent context across turns and runs.

In practiceA travel-planning assistant pulls the user's long-term seating preferences and the prior session's unfinished itinerary from memory, so it resumes mid-task without the user restating either.

Level
04 · Production
Subdomain
Memory Architecture
Also known as
Conversational Memory, Episodic Memory, Working Memory / Scratchpad, Memory Management
Trade-off
Improved context and adaptability are achieved against higher token costs, privacy risks, and context window exhaustion.
Native in
LangGraph, OpenAI Agents SDK, Microsoft Agent Framework, AutoGen / AG2, CrewAI
The effect

What it actually does.

The run writes facts now and recalls them on a later turn.

storememoryrecall
Walk it through

A real run, step by step.

TaskA travel assistant receives one message: “Book the same hotel as last time, but two nights longer.” Each part of the answer comes from a different store:
Illustrative setup.
StoreWhat it suppliesLives for
Conversational memoryThe last turns of this chat: the trip is to Lisbon, in MayThis session
Episodic memoryThe last trip: Hotel Avenida, three nights, the card needed a second attemptAcross sessions, for this user
Semantic memoryStable facts about the user: quiet room, no early check-out, loyalty numberAcross sessions, for this user
Working memoryThe plan the agent builds from these: Hotel Avenida, five nights, price still to confirmThis run
RAG, not memoryThe hotel's cancellation policyUntil the hotel changes it; the same for every user
What this shows: “the same hotel as last time” and its three nights can only come from episodic memory. The plan that results lives in working memory and is gone when the run ends. The cancellation policy comes from retrieval: it does not come from this user's history, and it is the same for everyone. The price: four memory stores, and each one has to keep users apart, record where an entry came from, and be able to delete it.
Fit

Use it, or not.

When to reach for it

  • User context must be maintained across multiple turns.
  • The agent needs to learn from past cases.
  • Multi-step tasks require tracking intermediate states.

When it backfires

  • Privacy regulations forbid storage.
  • Tasks are strictly stateless.
  • A static semantic knowledge base suffices.
Pitfalls

Two ways this pattern will hurt you.

Memory bleeds across sessions

User A's private context leaks into User B's conversation because the retrieval layer doesn't filter by session ID.

Countermeasure

Tag every memory entry with a session or user dimension. Enforce dimension-scoped retrieval at the store layer.

Over-eager retrieval bloating context

The retriever fetches 20 relevant memories and dumps them into the prompt, crowding out the current turn's context.

Countermeasure

Cap retrieved chunks and rank by recency + relevance. Summarize old memories rather than inlining them verbatim.

Framework support

Where Memory Architecture is native.

LangGraphState and CheckpointersNative
OpenAI Agents SDKsessions + stateNative
Microsoft Agent Frameworkthreads + memoryNative
AutoGen / AG2conversable memoryNative
CrewAIshort/long-term memoryNative
Sources

Where this pattern comes from.

  1. Cognitive Architectures for Language Agents (CoALA)In the source list
  2. OWASP GenAI Data Security Risks & Mitigations 2026In the source list

Search

Search patterns, frameworks, and pages.