@kdotmahesh/kidneygrid

6
9
flwr new @kdotmahesh/kidneygrid

KidneyGrid

Kidney swaps across hospitals, with no patient data shared.

🎬 Watch the film and read the story: https://bouncypitch.github.io/kidneygrid/

How to run

KidneyGrid is a chat agent, so start it from Flower chat. (The Hub page's Run app button can't start AgentApps yet: SuperGrid requires a chat prompt, error code 44.)

In the browser

  1. Go to flower.ai/app and sign in.
  2. Choose a federation: @kdotmahesh/kidneygrid for the live network of hospital SuperNodes, or any other federation for a clearly labelled simulated 5-hospital exchange.
  3. Click New chat, select the agent KidneyGrid, and send one of:
    • Run the exchange: find the best swap loops (0 alone β†’ 3 first-come β†’ 5 KidneyGrid)
    • Approve the plan: surgeon approval, Transplant Day scheduling, courier booking
    • Approve the plan; an operating room may cancel: live re-planning after an emergency
    • Approve the plan; surgeon may reject: a surgeon declines a leg and the plan is rebuilt
    • Security test: inject attack: a prompt-injection attempt that hospitals refuse

In the terminal

uvx --from flwr==1.39.0 flwr login supergrid
uvx --from flwr==1.39.0 flwr chat
# at the ❯ prompt:
/federation @kdotmahesh/kidneygrid
@kdotmahesh/kidneygrid Approve the plan

95,492 people in the US are waiting for a kidney (OPTN, July 2026). Many have a loved one willing to donate who is the wrong match: at least a third of patients with a willing living donor are blocked by blood type or crossmatch incompatibility (Segev et al., JAMA 2005). Paired exchange fixes this by swapping donors between couples, but the couples are usually at different hospitals, and hospitals can't pool patient records: 62% of US exchange transplants stayed within one hospital, and fixing that fragmentation could add 30–63% more transplants (Agarwal, Ashlagi et al., AER 2019).

KidneyGrid puts a Flower agent in every hospital. Hospitals share only anonymous donor typing tokens and yes/no compatibility answers; a coordinator agent finds the best swap loops; surgeons approve before any identity is revealed.

How it works

Coordinator AgentApp (SuperLink)                 Hospital AgentApp (one SuperNode per hospital)
 1. get_nodes
 2. push REGISTER ─────────────────────────────▢ anonymous donor tokens (ABO + HLA), pseudonyms, cPRA bucket
 3. push CHECK (all tokens) ───────────────────▢ virtual crossmatch vs. OWN patients' antibodies β†’ yes/no only
 4. anonymous graph β†’ best loops (≀3-way, sensitized priority) vs. first-come baseline
 5. push CONFIRM ──────────────────────────────▢ surgeon approves / declines (category only; reason stays local)
 6. re-plan if declined
 7. push SCHEDULE ─────────────────────────────▢ which candidate days fit the PRIVATE OR/bed calendar
 8. push BOOK ─────────────────────────────────▢ reserve ORs; a local emergency can decline β†’ re-plan the loop
 9. push TRANSPORT ──▢ Courier AgentApp (its own SuperNode): cold-chain van per kidney (hospitals + day only)
10. push REVEAL ───────────────────────────────▢ identities released only for approved legs

Transplant Day. Every surgery in a loop must happen the same day, so hospitals agree a date from private calendars, re-plan the whole loop when an operating room is lost, and a courier company β€” a different kind of organization on the same federation β€” books transport for each kidney without seeing any patient data.

  • One AgentApp, two roles. The same FAB runs on the SuperLink and on every SuperNode; the role is picked from the Grid tools the runtime exposes (get_nodes/push_messages/pull_messages vs. push_reply_message).
  • Privacy enforced in code, not prompts. Hospital agents answer only four message types with deterministic handlers; the model never sees private records. A prompt-injection request returns unsupported request.
  • The model explains. The coordinator uses the runtime's model endpoint to explain the plan from redacted facts.

Powered by Endeavor 1.0

KidneyGrid uses Flower's newly released Endeavor 1.0 (flwrlabs/endeavor-1.0) inside the hospitals:

  • Where: each hospital's agent on its own SuperNode calls Endeavor through that node's Flower API key (FLWR_MODEL_API_KEY), at the moment surgeons are asked to approve a swap.
  • What it sees: only non-identifying facts (an incoming kidney, the sending hospital, the approval decision, and whether the patient is highly sensitized). Never names, antibody profiles or records.
  • What it writes: a one-line briefing for that hospital's surgeon, before any identity is revealed. Real output from a live SuperGrid run on Sept 29, 2026 (Bay General's agent):

    "The approved kidney from Valley Health is incoming for our highly sensitized patient at Bay General."

  • Safety: privacy-critical steps (matching, crossmatch checks, what leaves a node) are plain code, so the model adds judgment and language without touching private data. If Endeavor is unavailable the agent falls back to openai/gpt-5.6-sol; the chosen model is shown in the demo UI ("written by Endeavor 1.0 inside the hospital").

Results

ScenarioEach hospital aloneFirst-come matchingKidneyGrid
Demo: 5 couples, 5 hospitals03 (Maria left out)5
Simulated: 300 pairs, 10 hospitals (avg of 5)126160178 (+41%)
Highly sensitized patients matched (simulated)243557 (2.4Γ—)

Simulated pools follow Saidman et al. (2006) as specified by Roth, Sânmez & Ünver (AER 2007); hospital assignment is uniform. Saidman pools are denser than real ones, so absolute counts are optimistic.

Run it

uv sync
uv run pytest                                  # compatibility + optimizer scenarios
scripts/local_stack.sh                         # local SuperLink + 5 hospital SuperNodes
uv run python -m web.flower_client "Run the exchange"   # one live run, events to stdout
uv run uvicorn web.server:app --port 8765      # demo UI at http://127.0.0.1:8765

Local runs need [superlink.local-agent] (address 127.0.0.1:8000, insecure = true) in ~/.flwr/config.toml. On SuperGrid: uv run flwr login supergrid, register one SuperNode per organization (flwr supernode register keys/<id>.pub supergrid --name ... --location ...), add them to a deployment federation, start them with scripts/supergrid_nodes.sh (in our demo Capitol Hospital runs on a Nebius Serverless AI endpoint using the flwr/supernode:1.39.0-py3.12-ubuntu24.04 image with its key and records mounted under /tmp), then set KIDNEYGRID_SUPERLINK=supergrid and KIDNEYGRID_FEDERATION=@<account>/<federation> for the web app's Live mode. Hospital nodes are started with --node-config 'hospital="<id>"'.

Demo keys: 1 match Β· 2 approve + Transplant Day Β· 3 surgeon rejects Β· 4 prompt-injection attack Β· 5 operating room cancels Β· S scale Β· P peek at private records Β· L toggle Live/Replay.

Other scripts: scripts/make_replay.py (Replay-mode event logs), scripts/benchmark.py (scale study), scripts/family_pdf.py (one-page explainer), video/ (Remotion film and script).

Data and scope

All people, hospitals and records are fictional and synthetic. Compatibility is simplified (ABO + virtual crossmatch); real programs add antibody strength, donor age/size and logistics as further local checks. KidneyGrid is a hackathon prototype, not a medical device.

Built for the Flower Collaborative Agent Hackathon, Stanford, September 29, 2026.