Inspiration
Medical students need to practise history-taking, but simulated-patient actors are a bottleneck: they are paid by the hour, hard to schedule, and every slot counts. The Avelios challenge asked for what is missing: practice on demand, as often as you want, at 11 pm, with no one watching.
Real patients rarely tell you everything up front. So our goal was not a chatbot that knows medicine, but a patient: someone with a personality and feelings, who speaks in everyday words and holds details back until you ask the right question.
What it does
- Talk to a patient by voice or text, and interrupt them naturally.
- Ask the right questions: some details come out only when you ask specifically.
- See the patient react: tone of voice, mood and an animated 2D avatar change during the conversation.
- See what you missed on a history-taking checklist.
- Get your teacher's feedback by sending them a recording of your consultation.
- Create new patients: teachers can draft a case with AI, then review and edit it.
- Hear the consequences: after some consultations, the patient leaves a voicemail showing why a detail mattered.
How we built it
In 36 hours, the two of us built a React + TypeScript frontend and a Python/FastAPI backend, connected by one written contract for every message and route.
The backend relays audio between the browser and the OpenAI Realtime API. Hidden clinical facts and the API key stay on the server during a student consultation. Each patient is a JSON file, so a new patient needs no new code.
Actor and director
The language model is the actor. A rules-based director, with no LLM, tells it how to speak, never what is medically true. A small state machine tracks the patient's mood, with an intensity from 0 to 3. It reacts to things like empathy, rushing, repeated interruptions or bad news.
Two keys for locked facts
The full wording of a locked fact is not in the prompt. The model has to request it through a tool call, and the server checks the student's actual question against the patterns allowed for that fact. For a locked fact $f$ with patterns $P_f$ and student question $q$:
$$ \text{answer}(f, q) = \begin{cases} \text{full detail} & \text{if the model requests } f \text{ and } q \text{ matches } P_f \ \text{vague first answer, or less} & \text{otherwise} \end{cases} $$
Interruptions
When the student talks over the patient, we cancel the reply and cut the model's memory of it down to what was actually played:
$$ t_{\text{kept}} = \min\left(t_{\text{played}},\ t_{\text{received}}\right) $$
This way the patient does not "remember" saying words the student never heard.
Feedback you can check
For feedback, the evaluation model writes no text. For each checklist item, it only returns which student question covered it, or nothing. The server rejects unknown items and invalid references, and the student can see the question matched to each covered item. With $N$ items, where $q_i$ is the question that covered item $i$:
$$ \text{covered} = \left|{\, i \in {1, \dots, N} : q_i \neq \varnothing \,}\right| $$
Challenges we faced
Latency
For voice turns, the delay the student feels includes the time the system waits to be sure they have stopped speaking:
$$ L_{\text{perceived}} \approx T_{\text{silence}} + T_{\text{first audio}} $$
We measured a median time to first audio of about 670 ms. With our default silence window of 500 ms, that is roughly 1.2 s, within our 1.5 s target. This is an estimate that leaves out some playback and network delay.
Tool calls were the expensive part. In our development logs, the median time to the first text token was 0.54 s without a tool call ($n = 1000$) and 2.04 s with one ($n = 148$). So tools are reserved for the moments that need them.
We also tried classifying each voice question before the patient replied. We rejected the idea because the transcript arrived too late: a median lag of about 314 ms ($n = 10$), above our 300 ms limit.
Keeping secrets
A language model wants to be helpful, while a realistic patient does not volunteer everything. Prompt rules alone were not enough. We removed locked details from the prompt and added the server-side check. This reduces leaks, but it does not eliminate every disclosure mistake.
Acting, not narrating
When we told the model which emotion to feel, it described it, for example by saying that it was shocked. We changed the director to send instructions about delivery instead: rhythm, length, pauses and voice.
Real conversations are messy
Noise and filler words can look like interruptions, and a transcript can arrive after the patient has started replying. We added rules for what counts as a real interruption when reacting to the student, and made locked facts stay locked if the transcript does not arrive in time.
An avatar must not invent symptoms
A gesture or a facial expression can look like a clinical sign. The avatar therefore touches the chest or jaw only when the patient's own words support it, and its moods are designed not to look like signs of illness.
A limited API budget
We built a mock mode for interface work, a text mode for cheaper testing, and an offline test suite. 981 offline tests pass. They test our code, not the behaviour of the live model, so we also wrote scripted live checks for leaks, unlocks, answer length, medical jargon and staying in character.
What we learned
- A prompt is not a guarantee. If something must not be said too early, it is safer to keep it out of the model's context.
- Let the model act and let code decide. Simple rules are easier to test and explain.
- Realism lives in the details: short answers, interruptions, hesitation and tone matter as much as medical content.
- Measure before choosing. Latency numbers helped us reject an idea that looked good on paper.
- Models involve trade-offs. In our microphone test, the full realtime model gave clearly more audible emotion than the mini model, with similar latency but a much higher cost.
- One lucky demo proves little. Offline tests, scripted live checks and honest notes on failures tell us much more.
- Agree on the interface first. A written contract helped the frontend and backend grow side by side.
What's next
Medical review of the cases and the feedback checklist, fewer disclosure mistakes, more testing with real voices and noisy rooms, and feedback on how students communicate, not only on what they ask.
MedVox is an educational prototype with fictional medical histories. It is not a medical device.
Built With
- audioworklet
- canvas
- css3
- fastapi
- git
- headaudio
- html5
- javascript
- json-schema
- mediarecorder
- node.js
- openai
- openai-realtime-api
- openai-responses-api
- oxlint
- pydantic
- pytest
- python
- typescript
- uvicorn
- vite
- web-audio-api
- websockets