Memory Conceptual Overview

Status: ACTIVE (pulled from docs.langchain.com) Source: https://docs.langchain.com/oss/python/concepts/memory Timestamp: 2026-05-11

Two Types of Memory

Short-Term Memory (Thread-Scoped)

Tracks ongoing conversation within a session. LangGraph manages this as part of agent state, persisted via thread-scoped checkpoints.

State includes: conversation history, uploaded files, retrieved documents, generated artifacts.

Managing long conversations: LLM context windows are limited. Techniques: summarization of older messages, trimming to token limits, filtering non-essential messages.

Long-Term Memory (Cross-Thread)

Stores data across sessions and threads. Scoped to custom namespaces (not just thread IDs). LangGraph provides the Store interface.

Memory Types (from Cognitive Science)

Type What is Stored Human Example Agent Example
Semantic Facts School learning User facts, preferences
Episodic Experiences Past events Past agent actions, few-shot examples
Procedural Instructions Motor skills Agent system prompt

Semantic Memory Approaches

Profile: Single, continuously updated JSON document. Simple but error-prone as it grows.

Collection: Multiple documents continuously updated. Higher recall, but more complex search and update logic.

Episodic Memory

Often implemented via few-shot example prompting. Agent learns from past sequences to perform correctly. Can use LangSmith Datasets for developer-controlled examples.

Procedural Memory

Combination of model weights, agent code, and prompts. Agents rarely modify weights/code but can refine their own instructions via "Reflection" (meta-prompting).

Writing Memories

Memory Storage

Long-term memories stored as JSON documents in a Store:

store = InMemoryStore(index={"embed": embed, "dims": 2})
namespace = ("user_id", "context")

store.put(namespace, "memory_key", {"rules": ["..."], "data": "..."})
item = store.get(namespace, "memory_key")
items = store.search(namespace, filter={"key": "value"}, query="search query")

See the Persistence guide for full Store usage.