Asako HayaseAsako Hayase
Technical Tutorial

How I Built a Movie Recommendation Agent That Actually Remembers Your Preferences

Learn how to create persistent memory-enhanced AI agents using Strands Agents and Mem0

August 7, 2025
How I Built a Movie Recommendation Agent That Actually Remembers Your Preferences

Ever wished your AI assistant could remember that you love Life Is Beautiful or hate horror movies? Most AI agents suffer from a critical limitation: they forget everything the moment your conversation ends. But what if we could build agents with persistent memory that learn and evolve based on your preferences?

I built a movie recommendation agent using Strands Agents and Mem0 that demonstrates exactly this capability. The agent doesn't just recommend movies—it learns your tastes, remembers your ratings, and gets better at suggestions over time, even across different sessions.
Watch my YouTube tutorial here: https://www.youtube.com/watch?v=m0sRdeM9RZE

The Memory Problem in AI Agents

Traditional AI agents face a fundamental challenge: statelessness. Every conversation starts from scratch, leading to several frustrating problems:

  • Repetitive Interactions: Users constantly re-explaining their preferences
  • No Personalization: Generic responses that don't reflect individual tastes
  • Lost Context: Previous conversations provide no value for future interactions
  • Inefficient Experiences: Users waste time providing the same information repeatedly

This is particularly painful for recommendation systems, where personalization is everything. Your movie agent should know you prefer drama over sci-fi, remember that you rated Love Actually 5 stars, and understand that you generally dislike horror films.

Introducing Persistent Memory with Mem0 and FAISS

The solution lies in persistent memory—the ability for agents to retain and recall information across sessions. This project demonstrates how to achieve this using:

  • Mem0: A production-grade memory layer that automatically extracts, stores, and retrieves relevant facts
  • FAISS: Fast vector similarity search for efficient memory retrieval
  • Strands Agents: Open-source agent framework that simplifies tool integration

Key advantages of this approach:

  • Local Storage: No external databases required—everything runs locally with FAISS
  • Automatic Processing: Mem0 intelligently extracts facts from natural language
  • Semantic Search: Vector embeddings enable contextual memory retrieval
  • Production Ready: Handles memory deduplication, updates, and lifecycle management

Movie Recommendation Assistant Architecture

architecture

Architecture

The system combines Strands Agents with Mem0's memory capabilities:

  • Strands Agent: Core conversational AI with tool integration
  • Mem0 Memory: Memory operations (store, retrieve) and preference extraction
  • FAISS Vector Database: Local persistent storage for memory embeddings
  • Custom Tools: Specialized movie rating and recommendation tools
  • Movie Database: Curated collection of movies with genres and series information
  • Amazon Bedrock: Multiple Claude models - Claude 4 Sonnet (main agent), Claude 3.5 Haiku (memory processing), and Titan Text v2 (embeddings)

Memory & Recommendation Flow

The movie recommendation agent uses different tool combinations depending on the user's request. Here are the detailed flows:

Comedy Recommendation Flow

User: "recommend comedy movies"

Strands Agent: Process Query & Plan Reasoning

Execute Tools: recommend_movies tool

recommend_movies tool:
1. Calls Mem0 Memory (action="retrieve", query="comedy preferences")
2. Mem0 internally:
- Uses Claude 3.5 Haiku for memory processing
- Searches FAISS vector store for relevant memories
- Returns user preference data
3. Accesses Movie Database (Python data structure)
4. Applies scoring algorithm based on:
- User's genre preferences from memory
- Movie ratings and genres
- Preference-based boosts/penalties
5. Returns top-rated comedy recommendations

Strands Agent: Generate Response using recommendations

Movie Rating Flow

User: "I rate Inception 5 stars"

Strands Agent: Process Query & Plan Reasoning

Execute Tools: rate_movie tool

rate_movie tool:
1. Searches Movie Database for "Inception"
2. Finds matching movie and any series information
3. Creates structured memory content:
- "User rated 'Inception' 5/5 stars"
- "User liked this movie"
- "Genres: sci-fi, thriller"
- Genre preference: "User likes sci-fi, thriller movies"
4. Calls Mem0 Memory (action="store", content=rating_info)
5. Mem0 processes and stores in FAISS vector database
6. Returns success confirmation

Strands Agent: Generate confirmation response

Quick Start

Prerequisites

  • Python 3.10+
  • AWS account with Bedrock access (see setup below)
  • (Optional) API keys for cloud memory backends (Qdrant, OpenSearch)

AWS Bedrock Setup

1. Create AWS Account

Go to aws.amazon.com and create an account.

2. Enable Bedrock Access

  • Navigate to Amazon Bedrock in the AWS Console
  • Go to Model access
  • Request access to the following models:
    • Claude 4 Sonnet - Used by your main agent
    • Claude 3.5 Haiku - Used by Mem0 for fast fact extraction
    • Amazon Titan Text Embeddings v2 - Used by Mem0 for vector embeddings
  • Wait for approval (usually instant for most accounts)

3. Create IAM User with Bedrock Permissions

  1. Go to IAM service in the AWS Console
  2. Click UsersCreate user
  3. Enter a username and click Next
  4. Select Attach policies directly
  5. Search for and select AmazonBedrockFullAccess
  6. Complete user creation
  7. Go to the new user and click Create access key
  8. Choose Application running outside AWS and create keys
  9. Download or copy the Access Key ID and Secret Access Key

4. Configure AWS Credentials

1aws configure
2# Enter your Access Key ID
3# Enter your Secret Access Key

Installation

  1. Clone the repository
1git clone https://github.com/asakohayase/strands-agents-memory.git
2cd strands-agents-memory

2. Install dependencies

1uv sync

3. Run the Assistant

1uv run python main.py

📋 Usage Examples

🎬 You: I love sci-fi movies with complex plots
🤖 Agent: I'll remember that you enjoy sci-fi movies with complex plots...

🎬 You: I didn't like The Matrix
🤖 Agent: What would you rate The Matrix on a scale of 1-5 stars?

🎬 You: 2 stars
🤖 Agent: Thanks! I've stored your rating...

🎬 You: Recommend some comedies
🤖 Agent: Based on your preferences, here are some comedy recommendations...

Core Implementation

Movie Recommendation Assistant Setup

recommend_movies.py
1from strands import Agent
2from strands_tools import mem0_memory, use_llm
3
4class MovieRecommendationAssistant:
5    def __init__(self, user_id: str = "demo_user1"):
6        self.agent = Agent(
7            system_prompt=SYSTEM_PROMPT,
8            tools=[mem0_memory, use_llm],
9            load_tools_from_directory=True,
10        )

Rate Movie Tool

rate_movie_tool.py
1@tool
2def rate_movie(movie_title: str, user_rating: float, liked: bool) -> Dict[str, Any]:
3    matched_movie = get_movie_by_title(movie_title)
4    movies_to_rate = [matched_movie]
5    if matched_movie.series:
6        movies_to_rate = get_movies_by_series(matched_movie.series)
7    
8    memory_entries = []
9    for movie in movies_to_rate:
10        memory_content = f"User rated '{movie.title}' {user_rating}/5 stars..."
11        memory_entries.append(memory_content)
12
13Recommend Movies Tool
14
15@tool
16def recommend_movies(user_memories: str = "", count: int = 5, genre_filter: str = None) -> Dict[str, Any]:
17    all_movies = get_all_movies()
18    for movie in filtered_movies:
19        score = movie.rating / 10.0
20        # Apply preference boosts/penalties
21    # Return sorted recommendations

Movie Database Structure

movie_database.py
1@dataclass
2class Movie:
3    id: str
4    title: str
5    year: int
6    genres: List[Genre]
7    rating: float
8    series: str = None
9
10class Genre(str, Enum):
11    ACTION = "action"
12    COMEDY = "comedy"
13    DRAMA = "drama"
14    HORROR = "horror"
15    ROMANCE = "romance"
16    SCI_FI = "sci-fi"
17    THRILLER = "thriller"
18    FANTASY = "fantasy"
19    DOCUMENTARY = "documentary"
20    ANIMATION = "animation"


Resources

🚀 Try It Yourself

📚 Learn More