Inspiration

In much of the world a single clinician may see 100 to 200 patients a day. At that load the bottleneck is not only speed — quality slips. A doctor with two minutes per patient can miss the allergy, the rising lab value buried in an old report, or the one red flag that mattered.

CareLoop is a force multiplier for doctors where doctors are scarce. It consistently surfaces the right history and flags the urgent cases, so quality holds up even under that load. It is decision support for a licensed clinician — never a diagnosis, and never a replacement for one.

We wanted to build an agent that closes that loop — one that reads the mess, decides urgency in a way a clinician can actually trust, and handles the follow-up on its own.

What it does

CareLoop is an autonomous clinical-triage agent. It runs the whole loop:

  1. Ingest & compact. It reads a patient's documents and merges them into one structured ledger — allergies, chronic conditions, active medications, and lab trends over time. Instead of pushing forty pages into context on every visit, later steps read the compacted ledger.
  2. Triage. A patient describes their symptoms and a deterministic engine scores probable conditions, assigns an urgency level, and routes to a specialty — with a red-flag override that escalates emergencies instantly.
  3. Brief the clinician. The agent writes a plain-language summary that pulls in the patient's history — surfacing, for example, a penicillin allergy before anything is prescribed.
  4. Write back. The clinician states their decision in the chat and the agent records it into the ledger, then bills the prescription plus the consultation fee (mock payment).
  5. Follow up autonomously. A background sweep decides who is due for a refill and who needs a check-in, and sends the reminder — so the medication a doctor prescribed today drives the reminder a month from now.

The core idea: rules decide, AI explains

The design principle runs through everything: a deterministic engine owns every clinical decision, and the LLM never does. A weighted score plus a red-flag override decides urgency and routing — fully auditable, the same input always giving the same output. Gemini's job is language: reading unstructured documents into a fixed schema ("Gemini extracts, rules merge") and turning the structured result into readable prose.

This is both a safety stance and a demo advantage: when a judge asks "why was this Critical?", the answer is a score breakdown they can inspect, not a model's say-so.

How we built it

  • Gemini 3.5 Flash via the Google Agent Development Kit (ADK) — the agent, its tools, and the dev UI.
  • Cloud Run — the agent is deployed on an always-on Google Cloud URL, with the web UI served from the same origin.
  • Firestore — the patient ledger persists in the cloud; the Cloud Run service account reads and writes it.
  • A deterministic Python engine — the triage scoring, the compaction merge, and the follow-up scheduler are pure Python with no model in the loop, backed by 34 tests including a reproducibility check.
  • Pluggable backends — local vs. cloud storage and mock vs. real email are one environment flip apart, so the whole system runs offline for testing and on Google Cloud for the demo.

Challenges we ran into

  • Auth and CORS. Getting the agent talking to Gemini through the right auth path, and getting the dev UI past Cloud Shell's proxy, took real iteration. We learned to isolate the front end from the engine to debug each cleanly.
  • Cloud Build permissions. The first Cloud Run deploy failed because the default build service account was missing IAM roles — a known gotcha we fixed by granting the build roles explicitly.
  • Keeping the LLM out of decisions. The discipline of "rules decide, AI explains" took deliberate design — making sure the model reads documents and writes prose but never sets a triage level.

What we learned

Determinism is a feature, not a limitation. The single most valuable thing we built is a triage engine that gives byte-identical output on the same input, every time — because that is the difference between a tool a clinician can sign off on and a chatbot that guesses.

What's next

  • Real document ingestion from Google Drive (service-account access).
  • Real transactional email and a real pharmacy integration.
  • A daily Cloud Scheduler trigger so the follow-up sweep runs entirely on its own.

A note on safety and data

All patient data in this project is synthetic. The symptom/condition dataset is demo-grade, not a medical reference. Output is decision support for a licensed clinician, never a diagnosis. Payment and email are mocked in the demo, and clearly labeled as such.

Built With

Share this project:

Updates