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.
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
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
| Collection | Profile, lesson 8 | |
|---|---|---|
| Shape | Many small memories | One document with fixed fields |
| Grows | Without limit | Never; fields are overwritten |
| Good for | Events, issues, anything open-ended | Current preferences and settings |
| Recall | Search, lesson 10 | Read 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.