The problem
Most fitness apps are passive. You log food. They store it. Nothing changes. Your plan stays the same whether you had a perfect week or ate pizza every day.
What I built
Adaptive HealthOS is a multi-agent AI system where 6 specialized Gemini agents autonomously manage your health — rewriting nutrition plans, updating goal forecasts, and keeping you accountable without manual intervention.
Log a meal and four agents fire in sequence:
- NutritionAgent recalculates your macros and updates your meal plan
- ForecastingAgent revises your goal completion date
- ProgressAnalysisAgent checks for plateau trends
- AccountabilityAgent awards XP and maintains your streak
Every decision is persisted to MongoDB Atlas and visible in the Agent Activity Panel — a real-time feed showing which agent fired, what it reasoned, and what it changed. This isn't a chatbot. It's a health operating system.
How I built it
Google Cloud ADK + Gemini 2.5 Flash
All 7 agents are built with the Google Cloud ADK (google-adk) using gemini-2.5-flash. The OrchestratorAgent classifies natural language intent and routes to specialist sub-agents via FunctionTool calls. The full chain — classify → route → execute → reassemble — runs in under 2 seconds.
orchestrator = LlmAgent(
name="OrchestratorAgent",
model="gemini-2.5-flash",
instruction=ORCHESTRATOR_PROMPT,
tools=[FunctionTool(get_user), FunctionTool(log_agent_decision)]
)
MongoDB Atlas — the persistent memory layer
MongoDB Atlas is the single source of truth for all agent state. Every agent read and write flows through mongodb_tools.py, which wraps Atlas operations (find, insert_one, update_one, aggregate) across 6 collections: users, health_logs, plans, agent_decisions, forecasts, gamification.
MongoDB MCP Server
I built mcp_server.py — a Python MCP Server using the official mcp SDK that exposes all MongoDB operations as Model Context Protocol tools (get_active_plan, insert_health_log, log_agent_decision, award_xp, and more). This is the defined MCP protocol layer for all agent-to-database communication.
The agent chain for a single food log: POST /api/logs/food → OrchestratorAgent classifies intent → FOOD_LOG → NutritionAgent: get_active_plan → get_daily_totals → update plan if surplus → NutritionAgent: log_agent_decision → award_xp → update_streak → ForecastingAgent: recalculate goal projection → update forecast → ProgressAnalysisAgent: detect trend → flag plateau if needed Stack
- Backend: Python 3.12, FastAPI, deployed on Railway
- Frontend: React 18 + TypeScript + Tailwind CSS + Recharts, deployed on Vercel
- Real-time: WebSockets for streaming agent responses
Challenges
Multi-agent state consistency. When NutritionAgent writes a plan and ForecastingAgent needs to read it immediately, ordering matters. I solved this with explicit async sequencing and confirmed MongoDB writes before triggering the next agent.
Gemini structured output. Getting gemini-2.5-flash to reliably output clean JSON for intent classification required strict system prompt constraints and fallback parsing logic.
ADK MCPToolset async lifecycle. Integrating MCPToolset as a live subprocess within ADK's agent lifecycle required careful async context management — a non-trivial engineering challenge I documented and solved in the MCP server architecture.
Demo cold starts. Railway cold starts added latency to the first agent call. Solved with always-on deployment configuration.
What I learned
- Stateful agents backed by persistent MongoDB are categorically more powerful than stateless LLM calls
- Multi-agent systems need explicit inter-agent contracts — each agent must know exactly what the previous one wrote
- Building the Agent Activity Panel first (making AI reasoning visible) made the entire system easier to debug and demo
gemini-2.5-flashis genuinely fast enough for real-time multi-agent chains
What's next
- Atlas Vector Search for semantic agent memory ("last time you had a calorie surplus week, here's what worked")
- Vertex AI Agent Builder for production deployment with built-in observability
- WhatsApp/SMS interface — log food by texting, agents respond
- Apple Health / Google Fit integration for automatic logging
Built With
- fastapi
- gemini-2.5-flash
- google-cloud-adk
- mongodb-atlas
- mongodb-mcp-server
- python
- railway
- react
- recharts
- tailwind-css
- typescript
- vercel
- websockets
Log in or sign up for Devpost to join the conversation.