§ case
HealthGpt
Jul 2025 — presentAI · Healthcare · Backend · Senior Software Developer · Architect
- —HexaHealth's AI gateway — a single Mastra agent runtime powering both a streaming text chatbot (SSE) and a realtime voice assistant (WebSocket bridged to Gemini Live) from one shared brain: same tools, memory, and knowledge base.
- —Retrieval-augmented generation over a namespaced Pinecone vector store spanning treatments, hospitals, doctors, listings, and user-uploaded medical PDFs, backed by an online ingestion pipeline and a query-rewriting symptom checker.
- —Persistent PostgreSQL memory — structured working memory plus semantic recall — hydrated per conversation from the CRM/EHR via LLM summarization, so the agent knows a user's lead stage and history with no extra lookup.
- —A server-authoritative, restart-safe booking engine owns the entire appointment flow end to end and never fabricates a lead.
- —Both channels are guarded against prompt injection and traced end to end in Langfuse, with sampled LLM-as-judge medical scorers grading response quality.
- —Agent prompts, models, and tools are DB-driven and hot-swappable without a redeploy; the service runs as a Docker container on a GCP instance.
Mastra AIGoogle Vertex AIGemini Live APIPineconePostgreSQLMySQLWebSocketSSELangfuseTypeScriptDockerGoogle Cloud Platform (GCP)
◼ Challenges
- →Serve a streaming chatbot and a realtime voice assistant from one runtime — without rebuilding tools, memory, and retrieval for each
- →Hold a natural voice conversation with no overlapping speech, and never leak system internals into the transcript
- →Ground answers in a large, changing medical catalog and each user's real patient context — while never inventing history or booking a lead that shouldn't exist
◼ Solutions
- →A single Mastra agent runtime and shared thread behind both surfaces — text and voice resume the same conversation and memory
- →A voice turn state machine with barge-in handling, plus buffered transcript sanitization to strip working-memory and tool leaks
- →Namespaced Pinecone RAG + CRM/EHR context hydration, and a tiered server-authoritative booking engine that parses and grounds every answer before creating a lead
