Skip to main content
This example demonstrates how to build a healthcare assistant that remembers patient information across conversations using Google ADK and Mem0.

Overview

The Healthcare Assistant helps patients by:
  • Remembering their medical history and symptoms
  • Providing general health information
  • Scheduling appointment reminders
  • Maintaining a personalized experience across conversations
By integrating Mem0’s memory layer with Google ADK, the assistant maintains context about the patient without requiring them to repeat information.

Setup

Before you begin, make sure you have: Installed Google ADK and Mem0 SDK:

Code Breakdown

Let’s get started and understand the different components required in building a healthcare assistant powered by memory

Define Memory Tools

First, we’ll create tools that allow our agent to store and retrieve information using Mem0:

Define Healthcare Tools

Next, we’ll add tools specific to healthcare assistance:

Create the Healthcare Assistant Agent

Now we’ll create our main agent with all the tools:

Set Up Session and Runner

Interact with the Healthcare Assistant

How It Works

This healthcare assistant demonstrates several key capabilities:
  1. Memory Storage: When Alex mentions her headaches and penicillin allergy, the agent stores this information in Mem0 using the save_patient_info tool.
  2. Contextual Retrieval: When Alex asks about headache causes, the agent uses the retrieve_patient_info tool to recall her specific situation.
  3. Memory Application: When discussing medications, the agent remembers Alex’s penicillin allergy without her needing to repeat it, providing safer and more personalized advice.
  4. Conversation Continuity: The agent maintains context across the entire conversation session, creating a more natural and efficient interaction.

Key Implementation Details

User ID Management

Instead of passing the user ID as a parameter to the memory tools (which would require modifying the ADK’s tool calling system), we attach it directly to the function object:
Inside the tool functions, we retrieve this attribute:
This approach allows our tools to maintain user context without complicating their parameter signatures.

Mem0 Integration

The integration with Mem0 happens through two primary functions:
  1. mem0_client.add() - Stores new information with appropriate metadata
  2. mem0_client.search() - Retrieves relevant memories using semantic search
The threshold parameter in the search function ensures that only highly relevant memories are returned.

Conclusion

This example demonstrates how to build a healthcare assistant with persistent memory using Google ADK and Mem0. The integration allows for a more personalized patient experience by maintaining context across conversation turns, which is particularly valuable in healthcare scenarios where continuity of information is crucial. By storing and retrieving patient information intelligently, the assistant provides more relevant responses without requiring the patient to repeat their medical history, symptoms, or preferences.

Tag and Organize Memories

Categorize patient data by symptoms, history, and visit context.

Support Inbox with Mem0

Apply similar memory patterns to customer support workflows.
Using Mem0? Star us on GitHub to help more developers discover memory for AI apps.