Data Engineering & Data Science — Internal Workshop

LLM Agent Memory
Foundations & Architectures

Part 1/2 — Theory: from cognitive psychology to LangGraph & DeepAgents
Target duration: ~50 min + questions  ·  Session 2: hands-on implementation (LangGraph, DeepAgents, notebook)
September 2026

Version française

Agenda

Two sessions, one thread

Session 1 — Theory (today)

  • Why memory is a real engineering problem, not a detail
  • The reference taxonomy (CoALA): working / long-term memory
  • How we retrieve, score, summarize, forget — with a bit of math
  • MemGPT / Letta, and modern "context engineering" (Anthropic)
  • A comparison of the major families of approaches

Session 2 — Practice

  • Short-term memory in LangGraph (checkpointer, threads)
  • Long-term memory (Store, namespaces, semantic search)
  • Agent-driven memory (langmem)
  • DeepAgents: sub-agents, virtual filesystem, backends
  • Live notebook demo + exercises for the team
Motivation

Why this topic, and why now

Goal of this session: give you a precise, shared vocabulary for talking about agent memory, before we dive into code in session 2.
The two tools we'll use

LangGraph & DeepAgents, in one minute

LangGraph

LangChain's agent orchestration framework: an agent is modeled as a state graph (nodes = steps, edges = transitions), with native support for persisting that state.

DeepAgents

A "batteries-included" agent harness built on top of LangGraph, explicitly inspired by Claude Code's behavior: planning, sub-agents, virtual filesystem — shipped by default rather than something you code yourself.

Why this matters for this talk: both treat memory as a first-class citizen — that's why they run as a thread through all of Session 1, even before we revisit them in detail at the end.
The central problem

The context window is finite

Everything an LLM "knows" at a given instant t fits inside a fixed token budget, shared between:

system prompt + tool schemas + conversation history + retrieved documents  ≤  N tokens

N = the context window size of the model in use — fixed for a given model (e.g. 200k tokens for Claude), but never infinite.

"Stuffing everything into the context" is not a free memory strategy: it's a choice with a quality cost, not just a latency/$ cost.
Definition

What is agent "memory"?

An agent's memory is any mechanism that lets information persist beyond a single pass through the model's context — and brings it back at the right moment.
Reference framework

CoALA — Cognitive Architectures for Language Agents

Sumers, Yao, Narasimhan & Griffiths — arXiv:2309.02427, TMLR 2024

This is the taxonomy that nearly all modern frameworks — LangGraph and DeepAgents included — adopt (implicitly or explicitly).

Short-term Working memory

The active content of the current decision cycle: what is literally in the context window at instant t. Volatile, not persisted by itself.

Long-term Long-term memory

What survives beyond a single cycle: three families, borrowed from cognitive psychology (next slide).

CoALA — Long-term memory

Three families of long-term memory

Episodic

Traces of past events: "at turn 12, the user said X, the agent did Y". Autobiographical memory.

Semantic

Factual knowledge, generalized from experience: "the user's manager is named Priya". Facts, ontology.

Procedural

The how-to: skills, rules, learned behaviors — inside the model's weights (implicit), or explicit (prompt, code, playbook).

You'll see this same three-way split reappear, under other names, in LangGraph (Store) and DeepAgents (filesystem + skills).
CoALA — the loop

The decision loop: 4 interacting actions

Working memory active, volatile Long-term memory episodic / semantic / procedural Outside world tools, environment 1. Reasoning 2. Retrieval 3. Learning 4. Grounding
1
Reasoning — new content in working memory.
2
Retrieval — long-term memory → working memory.
3
Learning — working memory → long-term memory.
4
Grounding — tool calls, environment (outside world).

It's this retrieval ↔ learning cycle around a limited working memory that is, ultimately, "the" engineering problem of agent memory.

Retrieval

How memory gets retrieved

write (once per memory) Memory (text) embed() vector read (at every query) Query (text) embed() vector cosine, top-k Long-term store top-k Working memory
A bit of math (1/3)

Cosine similarity

The one formula you really need to understand dense search: it measures the angle between two vectors, not their magnitude.

cos(u, v) = (u · v) / (‖u‖ · ‖v‖)
That's all the math you need to remember for 90% of vector memory systems in production.
A bit of math (2/3)

The retrieval score from "Generative Agents"

Park, O'Brien, Cai, Morris, Liang & Bernstein — Stanford/Google, UIST 2023 — arXiv:2304.03442

Each memory is a timestamped event in a memory stream. To decide what to recall, three signals are combined:

score = αr·recency + αi·importance + αv·relevance

(in the paper, all three α = 1; each term is min-max normalized to [0,1] before summing, so none dominates purely by scale)

A bit of math (3/3)

Recency: an exponential decay

recency = γΔt   (γ = 0.995, Δt in "hours" since last access)

Importance & relevance

Consolidation

Reflection: from episodic to semantic

This is the direct conceptual ancestor of the "memory consolidation" / hierarchical summarization found in nearly every modern framework (LangGraph included, session 2).
Since the 2023-2025 papers cited above

Temporal knowledge graphs: memory that invalidates, not overwrites

Rasmussen et al. (Zep), A Temporal Knowledge Graph Architecture for Agent Memory, 2025 — arXiv:2501.13956

Benchmark caveat: LoCoMo leaderboard numbers for Mem0/Zep/others are self-reported under different eval setups and are not directly comparable — treat any single "SOTA" claim in this space with suspicion.
An alternative architecture

MemGPT: the agent as an operating system

Packer, Fang, Patil, Lin, Wooders & Gonzalez (UC Berkeley) — arXiv:2310.08560

Main context (≈ RAM) LLM core memory (editable) External context (≈ disk) archival memory (embeddings) recall memory (raw history) core_memory_append / _replace archival_memory_search / _insert conversation_search

Main context (≈ RAM)

What fits in the model's window: system instructions, a window of recent messages, and blocks of "core memory" editable by the model itself.

External context (≈ disk)

Everything else, outside the window: archival memory (archived memory, facts/documents searched via embeddings) and recall memory (complete raw, searchable history).

MemGPT — mechanics

The model manages its own memory, via tools

Comparison

Five families, one spectrum

ApproachComplexityLatency/costReliabilityGood for
Raw context (stuff everything)NoneGrows with historyDegrades (Context Rot)Very short prototypes
Memory RAG (embeddings)MediumLow per turnGood, but recall silently incompleteMulti-session personalization
MemGPT / Letta (OS-style paging)HighExtra tool callsDepends on the model's self-disciplineLong and multi-session runs
LangGraph StoreLow if already on LangGraphCheap lookupHigh, explicit, testablePer-user/org personalization
DeepAgents (filesystem + sub-agents)Medium (opinionated harness)More LLM calls, but smaller parent contextStrong for long single-session tasks"Long-task" agents (research, code)
Anthropic memory tool (client-owned files)LowExtra tool calls, cheapHigh — you own storage & validationMulti-session agent progress, without adopting a framework

These approaches combine more than they compete — DeepAgents, for example, builds directly on LangGraph's Store (session 2).

The bridge to modern practice

"Context engineering": Anthropic's vocabulary

Anthropic formalizes context as a finite resource with diminishing returns — and names 4 techniques that show up, productized, in DeepAgents.

"Effective context engineering for AI agents" — anthropic.com/engineering

The 4 context engineering techniques

1. Compaction

Summarize a conversation approaching the context limit, then continue with the summary (+ the most recently accessed files).

2. Structured note-taking

A persistent notes file outside the context window, to survive a reset and pick back up where things left off.

3. Multi-agent architectures

An "orchestrator" agent synthesizes; specialized sub-agents work with their own, clean, isolated context window.

4. Just-in-time retrieval

Keep lightweight references (paths, identifiers) rather than the full content, and only load it when it's actually needed.

Anthropic, concretely

The memory tool: a real mechanism, not just a name

Since September 2025, Anthropic ships a concrete answer to "structured note-taking": a memory tool Claude can call directly, no framework required.

Six commands over /memories

view, create, str_replace, insert, delete, rename — the same primitives as a text editor, scoped to one directory.

Client-side by design

Claude only requests file operations; your application executes them against storage you own (disk, DB, S3 — SDKs ship a local-filesystem helper). Anthropic never sees or stores the files.

Measured impact (Anthropic's own eval): +29% from context editing alone, +39% combined with the memory tool, and an 84% token reduction in a 100-turn web-search task — this is the same "compaction + notes outside the window" idea from two slides ago, now with a number attached.

anthropic.com/news/context-management · platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool

Don't conflate these three things

Memory tool vs. Claude.ai memory vs. ChatGPT "Dreaming"

WhatWho stores itWho decides what's writtenFor
API memory toolYou (client-side)Claude requests, your app can validate/rejectEngineers building agents
Claude.ai "Memory" (Topics)Anthropic-hostedAutomatic, user can view/edit/delete per topicEnd users chatting with Claude
ChatGPT "Dreaming" (OpenAI, 2026)OpenAI-hostedFully automatic — rewrites entries without being askedEnd users, less transparent by design
Anthropic's explicit design choice is the opposite of "Dreaming": Claude tells you when it uses a memory and asks before writing sensitive information. That's a deliberate transparency trade-off, not a capability gap.
Why it works

It's not just intuition — it's measured

The Context Rot study (Chroma, 2025), across 18 frontier models, shows:

Practical conclusion: compacting, isolating, and retrieving on demand isn't a cost optimization — it's also a quality optimization.
Transition

Where LangGraph and DeepAgents fit

CoALA (Session 1) Working memory Long-term memory DeepAgents (reuses LangGraph primitives) Checkpointer + thread_id Namespaced Store semantic search sub-agents → isolation virtual filesystem → offloading

DeepAgents is not a competitor to LangGraph: it's an opinionated layer on top of it — its own contribution is the filesystem metaphor + sub-agents, not a new persistence mechanism.

Summary

What to remember before session 2

Glossary (1/2)

Agent / LLM vocabulary

TermDefinition
FrameworkA software library that imposes structure: you write your code inside the rules it defines — as opposed to a plain library you simply call from your own code.
Harness (agent harness)The code wrapped around an LLM to turn it into a full agent: the decision loop, tool handling, memory and context management — the LLM alone doesn't know how to loop or call tools by itself.
OpinionatedImposing default design choices rather than leaving everything configurable (the opposite of "unopinionated"/neutral) — a trade-off between getting started fast and staying flexible.
Batteries-includedShipped with everything needed to be useful right away, without having to assemble third-party pieces yourself (a phrase borrowed from Python: "batteries included").
Model-agnosticWorks with any underlying LLM (Claude, GPT, ...) without being tightly coupled to one vendor.
TokenThe unit of text an LLM processes (roughly a word or word-fragment) — it's the unit the context window is measured in.
EmbeddingA numeric vector representing the "meaning" of a piece of text, produced by a dedicated model; texts that are close in meaning have vectors that are close together (see cosine similarity).
RAGRetrieval-Augmented Generation: injecting relevant documents fetched dynamically into the prompt, instead of relying only on what the model memorized during training.
Glossary (2/2)

LangGraph / DeepAgents vocabulary

TermDefinition
CheckpointerThe LangGraph component that saves a graph's state at every step so it can be resumed later (= short-term memory).
StoreLangGraph's namespaced key/value storage component, independent of threads (= long-term memory).
BackendIn DeepAgents, the system that decides where virtual files actually live (ephemeral state, a persistent Store, disk...); more generally, the part of a system handling storage/processing, invisible from the user-facing side.
GroundingAn agent acting on / perceiving the real world (tool calls, environment), as opposed to pure internal reasoning.
Context engineeringThe discipline (named by Anthropic) of actively managing what goes into an LLM's context window, rather than dumping everything available into it.
OffloadingMoving information out of the active context window (e.g. to a file) to free up token budget, to be re-read later only if actually needed.
Sub-agent (quarantine)A helper agent running in its own isolated context window; only its final result "crosses over" to the parent agent — intermediate noise never pollutes the parent's context (hence "quarantine").
Bibliography (1/2)

Academic foundations

Sumers, Yao, Narasimhan & Griffiths, Cognitive Architectures for Language Agents (CoALA), TMLR 2024 — arXiv:2309.02427
Park, O'Brien, Cai, Morris, Liang & Bernstein, Generative Agents: Interactive Simulacra of Human Behavior, UIST 2023 — arXiv:2304.03442 · ACM DOI 10.1145/3586183.3606763
Packer, Fang, Patil, Lin, Wooders & Gonzalez, MemGPT: Towards LLMs as Operating Systems, 2023 — arXiv:2310.08560
Zhang, Bo, Ma, Li, Chen, Dai, Zhu, Dong & Wen, A Survey on the Memory Mechanism of Large Language Model based Agents, ACM TOIS 2025 — arXiv:2404.13501 · DOI 10.1145/3748302
Wu, Liang, Zhang, Wang, Zhang, Guo, Tang & Liu, From Human Memory to AI Memory: A Survey on Memory Mechanisms in the Era of LLMs, 2025 — arXiv:2504.15965
Du, Memory for Autonomous LLM Agents: Mechanisms, Evaluation, and Emerging Frontiers, 2026 — arXiv:2603.07670
Chroma Research, Context Rot: How Increasing Input Tokens Impacts LLM Performance, 2025 — trychroma.com/research/context-rot

Bibliography (2/2)

Engineering, frameworks & tools

Anthropic, Effective context engineering for AI agents, 2025 — anthropic.com/engineering/effective-context-engineering-for-ai-agents
LangChain / LangGraph docs, Persistence (checkpointer & store, short vs. long-term memory) — docs.langchain.com/oss/python/langgraph/persistence
LangChain, New in Deep Agents v0.6, 2026 — langchain.com/blog/deep-agents-0-6
langchain-ai/deepagentsgithub.com/langchain-ai/deepagents
langchain-ai/langmemgithub.com/langchain-ai/langmem
letta-ai/letta (successor to the MemGPT project) — github.com/letta-ai/letta · letta.com/blog
Anthropic, Memory tool & Managing context on the Claude Developer Platform, 2025-2026 — platform.claude.com/.../memory-tool · anthropic.com/news/context-management
Chhikara, Khant, Aryan, Singh & Yadav, Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory, 2025 — arXiv:2504.19413
Rasmussen et al., Zep: A Temporal Knowledge Graph Architecture for Agent Memory, 2025 — arXiv:2501.13956

Questions?

Session 2 — in two weeks: LangGraph + DeepAgents in practice, with a notebook.