Inspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

Inspiration

A mile from where we built this, at Johns Hopkins Bayview, the median emergency-department visit runs 322 minutes — over five hours. At MedStar Franklin Square it's 367. Those are CMS's numbers, not ours.

What made us build it was learning why. In most of these cases the bed exists. Nobody has put the right patient in it yet, because every department can only see its own corridor: the ward doesn't know intensive care is about to free a bed, and the emergency department doesn't know the ward could discharge three people this hour. That's a coordination problem, not a capacity problem — and coordination is the one thing a group of agents is genuinely good at.

What it does

EmerFlow is a command board for an emergency department during a surge. Eleven AI agents — one for each of ten departments, plus a coordinator — argue in plain English about where each patient goes, and you watch them do it.

The rule that makes it safe: AI talks, code counts, a human approves the big moves.

No model ever does bed arithmetic or picks a bed number. It names a unit; code validates the move against the real state of the building and refuses bad ones out loud. Anything with a real cost — diverting ambulances, cancelling a surgery, calling in staff — stops and waits for a person, and what that person is shown is exactly what happens.

The agents also remember. Every promise a department makes is written down by code, not by the model, held for five hours, then forgotten like a shift handover. A 3D memory page shows each live note fading as it ages, which lets the swarm hold itself to account: "Following up: twelve of seventeen offered moves happened."

Alongside it, an EMS map reads the live Maryland MIEMSS feed — how crowded all 61 reporting hospitals are right now, how many ambulances are parked at each ER, and how long the longest-waiting crew has been stuck there.

How we built it

A Python/FastAPI simulation where every patient move takes one strict path, a Next.js board on server-sent events, and Gemini 2.5 Flash on Vertex AI for all eleven agents — one model, ten personas, so a round costs a dozen calls rather than a dozen models. Every model call has a rule-based fallback behind a timeout and a circuit breaker, so the board keeps placing patients with the wifi off. All patient data is synthetic.

Challenges we ran into

We pinned the agents to a preview model our project had no quota for. Every call returned 429, and the board ran 903 cycles entirely on rule-based fallbacks — placing patients correctly, chatting away — while the page confidently named a model it had never once reached.

We caught it only because we'd built an endpoint that counts how every call was actually answered: live, replay, stub or fallback. It read {"fallback": 11843, "live": 0}. We built that field so we couldn't fool ourselves, and then it caught us fooling ourselves.

Agent memory had the same shape of bug. Notes were capped at 60 per agent, which sounded like a safe bound and turned out to be the only bound that ever fired — the busiest department held nothing older than two minutes, while every page said five hours.

Accomplishments that we're proud of

Same patients, same beds, three seeded runs: coordination cut the average wait for a bed from 23.7 minutes to 0.9, and the longest single wait from 141 minutes to 12. At the end of the run, an average of 8.7 people were still waiting without coordination. With it, 0.3.

We'll also say what that doesn't prove. It measures coordination against no coordination, not Gemini against our own rule planner — and our own output says so, in a field called note.

What we learned

Build the instrument that can prove you wrong before you need it. Both of our worst bugs were invisible from the screen — the board looked healthy in each case — and both were caught by a number we had written specifically to check ourselves.

What's next for EmerFlow

Give the coordinator its own memory: the ten departments remember, and the thing writing the plan reads them fresh every round. Then a real EHR integration and clinical validation, which is the honest blocker — not the code.

What's next for Tema Emerflow

Built With

Share this project:

Updates

Submission history