Tathagat Agrawal

Clinic Agent: AI-assisted appointment scheduling

Patients describe their concern and get real appointment options with a suitable doctor. AI assists with intake and routing; deterministic code owns safety and booking, and everything works with the LLM switched off.

October 2026 · Complete (version 1) · Source on GitHub

Result: On 218 held-out cases, the trained department classifier chose an acceptable department 97.2% of the time with no wrong-specialist choices, against 85.3% and 8 wrong specialists for the hand-tuned router it replaced.

The problem

A patient writes a few words (“my left hand keeps going numb and tingly”) and needs appointment times with a suitable doctor. Doing that with an LLM is easy to demo and hard to trust: a model that diagnoses, picks the wrong specialist or writes to the schedule directly is a liability. This project draws a hard line: AI assists with intake and routing, but never diagnoses, never makes a clinical decision and never writes to the database.

This is the second, rebuilt version of my first AI clinic scheduler, which let a LangGraph agent drive the whole conversation.

What I built

The Choose a time page of the clinic app. For a described itchy rash, it offers three Dermatology appointments with Dr. Sameer Khan, each with experience, languages, the reason it matches and a Choose this time button.
Figure 1. The patient's description was routed to Dermatology, and each option says why it was offered. Demo data: the doctors and the concern are synthetic, and the LLM summary was switched off.

Result

I compared the original hand-tuned similarity router with the trained classifier on 218 held-out cases, written before any of this round’s training and evaluated once, and on two perturbed copies of them (typos, and the concern wrapped in chatty text).

Three bar charts comparing the similarity router and two classifiers on clean, typo and chatty held-out cases: acceptable choice, share sent to General Medicine, and wrong-specialist rate. The bge-base classifier is best on all three.
Figure 2. Routers on the 218 held-out cases and two perturbed copies. The bge-base classifier (green) is now the default.
Held-out, 218 cases Similarity router Classifier (bge-small) Classifier (bge-base, adopted)
Acceptable department 85.3% 93.1% 97.2%
Sent to General Medicine 55.5% 52.8% 47.2%
Wrong specialist 3.7% (8) 0.0% 0.0%

Tuning the classifier’s own settings made almost no difference; a larger embedding model was the only change with real headroom.

Limits

The routing data is synthetic, written by one author, and has not been reviewed by a clinician, so the held-out set is independent in content but not in style. The choice of bge-base was made after the first look at the held-out results. Version 1 has no multi-factor authentication for staff and no email or SMS notifications.

Built with

Embeddings and vector search, scikit-learn, Probability calibration, Experiment design and honest validation, LLM APIs (Gemini, OpenAI, OpenRouter), Prompt engineering, LLM and agent evaluation, Web APIs with FastAPI, SQL databases (PostgreSQL, SQLite), Testing and CI (pytest, GitHub Actions), Web front ends (HTML, CSS, JavaScript), Python