<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: prakhar gupta</title>
    <description>The latest articles on DEV Community by prakhar gupta (@prakhar_gupta_b11e41958ac).</description>
    <link>https://dev.to/prakhar_gupta_b11e41958ac</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4099828%2Fd5bddd96-c999-44e8-bc0f-81c47ea0e401.png</url>
      <title>DEV Community: prakhar gupta</title>
      <link>https://dev.to/prakhar_gupta_b11e41958ac</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prakhar_gupta_b11e41958ac"/>
    <language>en</language>
    <item>
      <title>Building CareLoop: an autonomous clinical-triage agent where rules decide and AI explains</title>
      <dc:creator>prakhar gupta</dc:creator>
      <pubDate>Sat, 29 Aug 2026 06:03:57 +0000</pubDate>
      <link>https://dev.to/prakhar_gupta_b11e41958ac/building-careloop-an-autonomous-clinical-triage-agent-where-rules-decide-and-ai-explains-4eja</link>
      <guid>https://dev.to/prakhar_gupta_b11e41958ac/building-careloop-an-autonomous-clinical-triage-agent-where-rules-decide-and-ai-explains-4eja</guid>
      <description>&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;A doctor gets eight minutes with a patient and forty pages of scattered&lt;br&gt;
history — lab reports, discharge notes, and pharmacy bills from three&lt;br&gt;
different clinics. So the history is effectively invisible at the exact&lt;br&gt;
moment it matters most. And when the visit ends, nothing follows up: the&lt;br&gt;
six-month course lapses at week five, the recheck never gets booked.&lt;/p&gt;

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

&lt;p&gt;There is a bigger reason this matters. In much of the world a single clinician&lt;br&gt;
may see 100 to 200 patients a day, and at that load the bottleneck is not only&lt;br&gt;
speed — quality slips. A doctor with two minutes per patient can miss an&lt;br&gt;
allergy, a rising lab value buried in an old report, or the one red flag that&lt;br&gt;
mattered. CareLoop is a force multiplier for doctors where doctors are scarce:&lt;br&gt;
it consistently surfaces the right history and flags the urgent cases, so&lt;br&gt;
quality holds up even under that load. It is decision support for a licensed&lt;br&gt;
clinician — never a diagnosis, and never a replacement for one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;CareLoop&lt;/strong&gt; is an autonomous clinical-triage agent. It runs the whole loop:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Ingest &amp;amp; compact.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Triage.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Brief the clinician.&lt;/strong&gt; The agent writes a plain-language summary that
pulls in the patient's history — surfacing, for example, a penicillin
allergy before anything is prescribed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write back.&lt;/strong&gt; 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).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follow up autonomously.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The core idea: rules decide, AI explains
&lt;/h2&gt;

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

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

&lt;h2&gt;
  
  
  How we built it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gemini 3.5 Flash&lt;/strong&gt; via the &lt;strong&gt;Google Agent Development Kit (ADK)&lt;/strong&gt; — the
agent, its tools, and the dev UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Run&lt;/strong&gt; — the agent is deployed on an always-on Google Cloud URL,
with the web UI served from the same origin.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firestore&lt;/strong&gt; — the patient ledger persists in the cloud; the Cloud Run
service account reads and writes it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A deterministic Python engine&lt;/strong&gt; — 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pluggable backends&lt;/strong&gt; — 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.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Challenges we ran into
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Auth and CORS.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Build permissions.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keeping the LLM out of decisions.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What we learned
&lt;/h2&gt;

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

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

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

&lt;h2&gt;
  
  
  A note on safety and data
&lt;/h2&gt;

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

</description>
      <category>googlecloud</category>
      <category>ai</category>
      <category>python</category>
      <category>hackathon</category>
    </item>
  </channel>
</rss>
