Module 5: Agent Memory¶
What you're building¶
Without memory, every conversation starts from zero. Your agent has no idea who it's talking to or what was discussed before.
Agent Memory gives your agent two types of memory:
| Memory type | What it stores | Lifetime |
|---|---|---|
| Session | Every message in the current conversation | Expires when the session ends |
| Long-term | User preferences and facts | Persists across conversations |
When someone asks "What plans would you recommend?", the agent searches long-term memory by meaning and recalls "travels to Canada frequently" and "prefers managing everything through the app" to give a personalized answer.
Cloud setup¶
1. Create an Agent Memory store¶
- In the Redis Cloud console, find Agent Memory in the left sidebar.
-
Click Quick Create.

2. Save your API key¶
Copy the API key immediately. You won't see it again.

Save it in your .env file:
3. Save your Endpoint and Store ID¶
Find the remaining credentials on the store details page:

Save them in your .env file:
4. Seed long-term memories¶
This seeds preferences for the demo customer: "Travels to Canada frequently for work" and "Prefers to manage everything through the app."
Exercise¶
- Open
exercises/telco/agent_memory.pyin your IDE. - Replace
return Nonein thelong_term_search_payloadmethod with:
return {
"text": text,
"similarityThreshold": 0.2,
"filterOp": "all",
"limit": limit or 5,
"filter": {
"ownerId": {"eq": sanitize_owner_id(owner_id)},
"namespace": {"eq": "telco-demo"},
},
}
The key field here is similarityThreshold. It controls how closely a memory needs to match the current question. Lower means the agent recalls more loosely related memories. Higher means it only recalls very direct matches.
Verify¶
Stop the running server (Ctrl+C) and restart:
Open localhost:3040.
- Ask: "What add-ons or plans would you recommend for me?"
- Click
Agent-memoryin the right activity panel. The agent recalled "travels to Canada frequently" and "manages everything through the app" from long-term memory to personalize its recommendations. - Ask a follow-up: "What would that cost on my current plan?". The agent remembers what you just discussed. That's session memory keeping the conversation coherent.
- Now try changing
similarityThresholdto0.8, restart, and ask the same question. Notice how a stricter threshold changes what the agent remembers.