An AI sleep companion that reasons over your CPAP and smartwatch data to provide clinical-grade, grounded insights.
Built for the Microsoft Agents League @ AI Skills Fest 2026 — Reasoning Agents track.
Sleep data is hard to understand. CPAP machines produce complex medical metrics (AHI, leak rates, event indices), and smartwatches produce massive amounts of lifestyle data (HRV, SpO2, sleep stages).
Sleep IQ bridges the gap. It's a multi-agent reasoning system that ingests your health data, analyzes multi-month trends, and provides personalized, grounded insights—complete with visible reasoning chains and source citations.
Whether you're managing sleep apnea with a CPAP machine or just trying to understand your Apple Watch data, Sleep IQ acts as your personal sleep clinician.
- 🧠 Best Reasoning Agent: Utilizes a 4-step multi-agent pipeline (Ingestion → Trend Analysis → Risk Assessment → Recommendation).
- 💡 Best Use of IQ Tools: Integrates Foundry IQ to ensure medical advice is grounded in AASM clinical guidelines (embedded KB + Azure AI Search).
- 🎗️ Hack for Good: Helps uncover undiagnosed sleep apnea by correlating SpO2 drops and HRV patterns in general smartwatch data.
- 👥 Accessibility Award: Built with high-contrast theme, screen-reader-friendly markup, and keyboard navigation.
Sleep IQ leverages a sophisticated architecture powered by Microsoft Azure AI Foundry (primary) with an OpenRouter fallback for local testing:
- Data Ingestion: Parses ResMed
STR.edf, Apple Health XML, Fitbit JSON, or generic CSV. - Statistical Engine: Computes severity scores, 95th percentiles, and detects multi-month trends.
- Reasoning Agent: An orchestrator agent that dynamically calls tools (
get_data_summary,get_trend_analysis,get_recent_nights) to build a complete picture of your health before answering any question. - Grounded Output: Every answer cites its reasoning steps and relies on medical knowledge constraints.
👉 View the full Architecture Diagram
- Python 3.10+
- Azure subscription with AI Foundry hub + AI Search (see setup guide below)
- OR OpenRouter API key (for local dev without Azure)
-
Azure AI Foundry Hub + Project
- Go to ai.azure.com → Create hub → Create project
- Deploy a model (e.g.
gpt-4o) - Copy the Project Connection String from project settings
-
Azure AI Search
- Go to portal.azure.com → Create Azure AI Search
- Choose Basic tier or higher
- Copy the endpoint URL and admin key
-
Seed the knowledge index
python scripts/seed_search_index.py
git clone https://github.com/yourusername/sleepiq-agent.git
cd sleepiq-agent
pip install -r requirements.txtCopy the environment template and add your Azure credentials:
cp .env.example .envEdit .env to include your Azure AI Foundry connection string (primary path):
AZURE_AI_PROJECT_CONNECTION_STRINGfrom your AI Foundry projectFOUNDRY_IQ_ENDPOINT,FOUNDRY_IQ_API_KEYfrom Azure AI Search- Or set
OPENROUTER_API_KEYfor local development without Azure
python app.pydocker compose up --buildThe app will launch at http://localhost:5000.
- Click "Load Demo Data" — loads 365 days of real CPAP data instantly
- Try clicking one of the suggested questions that appear below the chat
- Ask custom questions like "What's causing my AHI spikes?" or "Is my therapy working?"
- Click "Print" above the chart for a doctor-ready summary
Don't have CPAP data handy? Click the "Load Demo Data" button on the upload screen to load a complete, anonymized 365-day ResMed CPAP dataset and see the agent in action.
- Zero Data Retention: All data processing occurs entirely in memory during your active session. No health data is ever saved to a database or disk.
- Not Medical Advice: The agent is heavily constrained to avoid making definitive medical diagnoses, instead framing insights as patterns to discuss with a clinician.
Built by Rahul Rao for the Microsoft Agents League Hackathon.
