Long-Term Knowledge Storage and Retrieval › When to Use Long-Term Memory
Michael BrenndoerferJuly 3, 20251 min read
AI Agent HandbookAll chapters Part 6 of 15Memory and Retrieval - How Agents Remember
Long-Term Knowledge Storage and Retrieval › When to Use Long-Term MemoryOne section · Sections in this chapter7 / 13 ↓
Sections in this chapter13
Reading tools Definitions & inline links
Toggle tooltip visibility. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Not everything needs to be stored in long-term memory. Here's a practical guide:
Store in long-term memory:
- Personal facts (birthday, location, occupation)
- Preferences (favorite foods, music, work style)
- Important information (allergies, constraints, requirements)
- Project details that span multiple sessions
- Learned facts about recurring topics
Keep in short-term memory:
- Current conversation context
- Temporary working information
- Details specific to this session only
- Information that will become outdated quickly
You can even ask the assistant to decide what's worth remembering:
In[2]:
Codedef should_remember(self, information):
"""Use Claude to decide if information is worth storing long-term"""
response = self.client.messages.create(
model=self.model,
max_tokens=128,
system="Decide if this information should be stored in long-term memory. Answer only 'yes' or 'no' with a brief reason.",
messages=[
{
"role": "user",
"content": f"Should I remember this: {information}",
}
],
)
decision = response.content[0].text.lower()
return "yes" in decision