01 / HealthGpt
One agent brain behind a text chatbot and a realtime voice assistant, built for healthcare.
A single Mastra runtime serving streaming chat (SSE) and live voice (Gemini Live over WebSocket) from the same tools, memory, and knowledge base — grounded in real patient context and guarded by per-turn medical evals.
A healthcare assistant has to do two hard things at once: answer accurately from a large, changing medical catalog, and hold a natural realtime voice conversation — without overlapping speech, without leaking system internals into the transcript, and without ever inventing a patient's history or booking a lead that shouldn't exist. Most stacks solve one surface and rebuild everything for the other.
One Mastra agent runtime backs both surfaces. Retrieval runs over a namespaced Pinecone knowledge base (treatments, hospitals, doctors, listings, and user-uploaded medical PDFs) with an online ingestion pipeline. Persistent memory lives in PostgreSQL — structured working memory plus semantic recall — hydrated per thread from the CRM/EHR (leads, patients, calls) via LLM summarization, so the agent knows a user's lead stage, doctor, and history with no extra lookup. Ten agentic tools cover symptom checking, semantic search, document Q&A, and a server-authoritative appointment-booking engine. Voice bridges to Gemini Live over WebSocket behind a turn state machine with barge-in handling; every turn on both channels is traced in Langfuse with sampled LLM-as-judge medical scorers.
- Text and voice share one runtime, thread, and memory — a phone/CRM caller and an app user with the same number resume the same conversation
- Booking is server-authoritative: a tiered, restart- and multi-pod-safe flow that treats the model's inputs as hints and grounds every answer, so it never fabricates a lead
- Made on-connect memory writes non-blocking to remove a 2–3s stall before the voice assistant's first words
- Agent prompts, models, and tools are DB-driven and hot-swappable — tuned without a redeploy — behind prompt-injection defense, WS rate guards, and transcript-leak sanitization
One codebase serves both a streaming chatbot and a realtime voice assistant with shared memory and patient context, medical-safety evals on every sampled turn, and runtime-tunable agents — production-safe across text and voice.