LangMemLangMem 0.0.30 · LangGraph 1.2 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
18 small wins to finish your pathNext lesson

Collections: many small memories

By default each memory is a separate note, a collection. It can grow without limit, so what goes in is decided by your instructions and by later consolidation.

Example
first = manager.invoke({"messages": conversation})
later = manager.invoke({"messages": [{"role": "user", "content": "Order A-1002 arrived damaged too."}]})

for memory in first + later:
    print(memory.content.content)

Each call extracts from its own conversation. The second knew nothing about the first, so a real model could not have connected the two broken orders. Passing earlier memories as existing lets it, lesson 7.

Instructions decide what is kept

Example
manager = create_memory_manager(
    "anthropic:claude-sonnet-4-5",
    instructions="Keep only facts that change how we support this customer: contact preferences and problems with orders. Ignore small talk.",
)

Instructions are the most effective lever with a real model: they say what your app needs. The stand-in ignores them, since its rules are fixed, so this is shown and not run.

Collection or profile

CollectionProfile, lesson 8
ShapeMany small memoriesOne document with fixed fields
GrowsWithout limitNever; fields are overwritten
Good forEvents, issues, anything open-endedCurrent preferences and settings
RecallSearch, lesson 10Read the one document
Try it yourself
  • Extract from a conversation that mentions three orders.
  • Join both results and count duplicates if the same message is sent twice.
  • Write instructions for a travel agent's memory.

Little by little, you're building something great.