DEV Community

Zuhaib Ahmed
Zuhaib Ahmed

Posted on

# Building MediAssist: An AI Health Agent with Persistent Memory Using Qwen + MongoDB

Why I Built This

Millions of people around the world struggle to get reliable health information quickly.
I wanted to build something that could help — a conversational AI agent that not only
answers health questions but actually remembers you over time.

This is my journey building MediAssist for the Qwen Cloud Hackathon 2026.

What is MediAssist?

MediAssist is a conversational AI health information agent that:

  • Answers health questions in plain language
  • Remembers your name, allergies, and health history across sessions
  • Shows your full chat history (like ChatGPT)
  • Deployed live on Alibaba Cloud ECS

Live demo: http://47.84.195.213:8501

The Tech Stack

  • Qwen Cloud (qwen-plus) — The AI brain of the agent
  • MongoDB Atlas — Persistent memory storage
  • Streamlit — Web interface
  • Alibaba Cloud ECS — Cloud deployment (Singapore)
  • Python 3.9 — Backend language

Architecture

The architecture is straightforward:
User → Streamlit UI (Alibaba Cloud ECS)

Agent Logic (Qwen API)

MongoDB Atlas (memory storage)

The MemoryAgent Challenge

The most interesting part was implementing true persistent memory.
Most chatbots forget everything when you close the browser.
MediAssist doesn't.

I used two separate state variables in Streamlit:

  • memory_context — Never cleared, survives new conversations
  • messages — Display only, cleared on "New Conversation"

This means even when you start a fresh conversation,
the agent still knows who you are!

# When user starts new conversation
if st.button("New Conversation"):
    st.session_state.messages = []  # Clear display
    st.session_state.session_id = str(uuid.uuid4())
    # memory_context stays intact!
    st.rerun()
Enter fullscreen mode Exit fullscreen mode

MongoDB Collections

I designed three collections for MediAssist:

  • users — User profiles (name, email, allergies, conditions)
  • chat_history — Full conversation logs per session
  • symptom_logs — Health concern tracking over time

Biggest Challenge

Deploying on Alibaba Cloud ECS with CentOS 7 was unexpectedly tricky.
The default Python version was 3.6, which didn't support the modern
Qwen/OpenAI SDK. I had to compile Python 3.9 from source:

cd /usr/src
wget https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz
tar xzf Python-3.9.18.tgz
cd Python-3.9.18
./configure --enable-optimizations
make altinstall
Enter fullscreen mode Exit fullscreen mode

Then pyarrow (a Streamlit dependency) needed cmake 3.25+ but CentOS 7
only had 3.17. The fix was installing a pre-built pyarrow wheel:

pip install pyarrow==10.0.1
pip install streamlit==1.28.0
Enter fullscreen mode Exit fullscreen mode

What I Learned

  1. Qwen Cloud API is fully OpenAI-compatible — easy to integrate
  2. MongoDB Atlas is perfect for storing conversational AI memory
  3. Alibaba Cloud ECS free trial gives generous resources for hackathons
  4. Separating display state from memory context is crucial for persistent AI agents

What's Next

  • MongoDB Atlas Vector Search for semantic symptom matching
  • Multilingual support
  • Medication reminder system
  • Mobile app

Try It Yourself

Built for the Qwen Cloud Hackathon 2026 — MemoryAgent Track 🏆

Top comments (0)