Inspiration

Talking to patients is one of the hardest skills to practise in medical school. Real patients can't be rehearsed on, and sessions with trained actors are expensive, rare and hard to repeat. An LLM can play a patient at any hour, but only if it can be trusted. It mustn't give away the diagnosis, invent findings, or break character when a student pushes it. Its feedback also has to be grounded in what actually happened. We set out to build a simulated patient that is believable and robust, with the guardrails built into the system rather than left to a prompt.

What it does

PatientZero puts a medical student in a first consultation with an LLM-simulated patient.

  • The visit: the student sees an intake tile with the patient's name, age, sex and reason for visit. The vitals are hidden, and the student can reveal them one at a time. They interview the patient and take notes.
  • The patient: every case is a different person, built from a synthetic medical record, with their own symptoms, history, worries and personality. They speak in everyday language and open up or close down depending on how they're treated. They reveal sensitive things only when asked the right question.
  • The assessment: the student submits up to three diagnoses, each with findings for and against.
  • Feedback: a review agent gives structured, itemized feedback.
    • It checks every finding against what the patient actually said: was it found in the visit, never asked about, or wrong, and does it point the right way?
    • It flags evidence the student had but didn't use.
    • It names the vitals that mattered.
    • It suggests what would have been worth asking.

How we built it

  • Cases. Synthea generates synthetic patients. Our pipeline turns one symptom visit into a ground-truth case: illnesses, symptoms, history, medications and a random personality. An LLM adds occupation, lifestyle and how the complaint feels. Synthea has no visit-day vitals, so we generate them from per-symptom effects.
  • The patient brief. We chose to structure each case like a standardized-patient script with four disclosure tiers:
    • the opening complaint;
    • things the patient volunteers;
    • things they say once the topic comes up;
    • things they reveal only when asked directly.

A deterministic step fills it in, using a 271-term glossary pitched at the patient's health literacy.

  • The actor. One model call per turn, with strict structured output. It first records which facts it reveals, what unlocked them and what it made up. Only then does it write the reply. The case prompt never changes during a session, so it stays cached.
  • Emotions. A second small call judges how each student message moves the patient on five axes: tension, mood, trust, shame and dominance. Each move is weighted by the patient's disposition. The actor only ever sees words like "guarded".
  • Feedback. The review agent sees the true diagnosis, the student's assessment, and an evidence list. The list holds every fact the student could have learned and whether they did, plus the vitals, the intake details and anything the patient made up.
  • Stack. FastAPI and React/Vite/Tailwind, with a four-module Python uv workspace. Every model call runs on gpt-6.2-sol through the OpenAI Responses API, and token use is counted per call.

Guardrails

  • Information hiding. The patient model never sees the case or the diagnosis, only the brief.
  • Spoiler guard. Briefs, replies and made-up details are scanned for the diagnosis and its synonyms. A reply that still leaks after a retry is replaced with a neutral line.
  • Disclosure guard. A hidden fact counts as revealed only if the exact words that unlocked it appear in what the student said. The most sensitive tier needs a direct question.
  • Enforced structure. Outputs follow strict schemas. Code rejects rule breaks and asks again once, showing the model the errors.
  • Staying in character. "Are you an AI?" or "What do you think you have?" gets a puzzled patient, not an assistant.
  • Consistency. A state object tracks what was disclosed and what was made up, and the model sees it fresh every turn.
  • Checked feedback.
    • The diagnosis appears only after the visit is locked.
    • Every evidence ID the reviewer cites is checked against what the student actually learned.
    • Anything that can't be verified is flagged in the UI.

Challenges we ran into

  • LLMs want to help. A patient that knows a hidden fact tends to hint at it, and when asked "what do you have?" it wants to answer. Prompting wasn't enough. What worked was keeping information from the model and checking its output in code.
  • Consistency. "About a week" in turn 4 must not become "three days" in turn 12. That's why we keep a state object and a log of made-up details.
  • Synthetic data isn't clinical data. Synthea records symptoms as conditions, has no visit-day vitals, and produces contradictory social facts. Terms missing from the glossary silently vanished, so the patient denied them. Each problem needed its own fix, and some are still open.
  • Fair feedback without an answer key. A fixed list of alternative diagnoses would penalize reasonable ones nobody wrote down. Instead, we review the student's own differential against evidence the code can check. Testing still caught edge cases:
    • repeating something the patient made up was marked wrong;
    • the intake tile didn't count as known;
    • every vital counted as relevant.
  • Rare hangs. The SDK's defaults allowed a 10-minute timeout with two silent retries, across two calls per turn. Fixing this led to per-call time limits and a deadline for each turn.

Accomplishments that we're proud of

  • It works end to end, from a synthetic record to structured, itemized feedback in the browser.
  • The guardrails are enforced in code, not just requested in a prompt. Leaks, unearned disclosures and rule breaks are caught and corrected before the student sees them.
  • Every claim in the feedback is checked by code. That's the difference between "an LLM said so" and feedback a student can trust.

What we learned

  • Guardrails belong in the architecture. Keeping information from the model beats asking it to pretend, and checking its output beats asking it to be careful.
  • Order in structured output matters. Making the model decide what it reveals before it writes the reply made disclosure controllable.
  • An LLM judge needs something checkable. Requiring citations from a known evidence list made the review verifiable.
  • Synthetic medical data needs curation. It's a great starting point, but not a clean one.

What's next for PatientZero

  • Feedback on communication: did the student pick up on the patient's worries and explain things clearly?
  • A second checking model to catch facts the patient said without recording them.
  • Expert review: clinicians check the cases and calibrate the reviewer.
  • More illnesses, voice, progress tracking and more languages.

Built With

Share this project:

Updates

Submission history