Give your AI agents persistent memory with Redis-powered Agent Memory Server (AMS).
- Working memory for session context (auto-summarization, TTL)
- Long-term memory for persistent facts (semantic search)
- How Redis stores and retrieves AI memories
- OpenAI API Key - Required for embeddings and chat
# From repository root
cd java-springboot/workshop-hub
# Start Redis + Workshop
docker compose -f docker-compose.local.yml --profile infrastructure up -d
docker compose -f docker-compose.local.yml --profile workshop-4_agent_memory up -dEnter your OpenAI API key when prompted.
| Stage | What You Do |
|---|---|
| 1. Problem | Understand why AI agents forget between sessions |
| 2. Solution | Implement working + long-term memory |
| 3. Demo | 8 guided tests to verify memory behavior |
- Working Memory Basics - AI remembers within a session
- Context Window Growth - Watch context % increase
- Store Long-Term Memory - Save facts that persist
- Semantic Search - Find memories by meaning
- Clear Working Memory - Session resets, facts remain
- Cross-Session Recall - New session retrieves old facts
- TTL and Lifecycle - Working memory expires
- Redis Insight - Explore memory data structures
Work through the same three files shown in the in-browser editor:
AgentMemoryService.javaImplement the core AMS SDK calls for working memory, long-term memory, and the health check.AmsChatMemoryRepository.javaBridge Spring AI conversation state to AMS, including context percentage lookup, conversation loading, deduplicated writes, and TTL setup.ChatService.javaPass the conversation ID into the advisor chain and enable the working-memory and long-term-memory advisors used by the chat demo.
The editor guidance follows this order: SDK client setup first, repository integration second, advisor wiring last.
| Type | Purpose | Example |
|---|---|---|
| SEMANTIC | Facts and preferences | "User prefers dark mode" |
| EPISODIC | Events with time context | "User went hiking on Saturday" |
| MESSAGE | Conversation excerpts | "User mentioned they work in tech" |
Working Memory:
KEYS working_memory:workshop:*
HGETALL working_memory:workshop:session-default
TTL working_memory:workshop:session-default
Long-Term Memory:
KEYS long_term_memory:workshop:*
FT.INFO idx:long_term_memory:workshop
- Working Memory - Session-scoped, auto-summarizes at 70% context, has TTL (1800s default)
- Long-Term Memory - Persistent, vector-indexed for semantic search
- Namespace - Isolates memories between applications
- Session ID - Groups working memory for a conversation
docker compose -f docker-compose.local.yml --profile workshop-4_agent_memory down