Inspiration
It's 11 p.m. Scan results reach a patient's phone before her doctor has called. At her next visit, she's prescribed a new drug, and nobody mentions that starting it could rule out clinical trials she might have joined.
Three problems shaped Inclusion:
- Symptoms go unreported between visits. In a randomized trial, electronic symptom monitoring during chemotherapy raised median overall survival from 26.0 to 31.2 months (Basch et al., JAMA 2017). That supports this kind of monitoring; Inclusion itself has not been clinically tested.
- Results can arrive before the call. Potentially cancer-diagnostic results seen this way carry higher odds of added worry (OR 1.55, Suresh et al., 2026).
- Trial options close silently. About 7 in 100 US adults with cancer take part in a treatment trial (Unger et al., 2024). Trials often exclude people who have had certain treatments, so a new drug can close one.
Tools that could help usually start by asking for a patient's records. Hybrid inference made the opposite possible: bring public medical knowledge to private data.
The cloud reads medicine. Your phone reads you.
What it does
Inclusion is a private companion for people living with cancer and the people who help them. It has four areas: Today, Doors, Records and Circle.
- Daily Pulse: Rosa, our synthetic patient, writes "mouth sores, can't eat much, felt hot last night 38.4". The on-device model finds symptoms and quotes the words behind each one. Then published rules, never AI, show a red card with her clinic's number first.
- Results Before the Call: Her report is read on her device. It shows what changed word for word, prepares questions for her care team and never interprets the results. When her blood count drops, 13 trials' blood-count rules stop passing. When it recovers, all 13 pass again.
- Visit Loop and Door Check: Her visit summary lists a new drug. Before the first dose, Inclusion warns that it would close 2 trials open to her today, one just 6 km away.
- Crossroads: It compares what each choice leaves open. In Rosa's demo, one drug closes 7 of 74 open trials and another closes 2. It never recommends one.
- Family circle: If her phone has no AI model, a trusted family device can answer her trial questions, end-to-end encrypted.
- Privacy ledger: She can see each request, its size and the kind of data involved.
Trial matching covers 485 real, recruiting US breast and lung cancer (NSCLC) trials from ClinicalTrials.gov. Daily Pulse, results and visits aren't tied to one cancer type. Inclusion says "possible match: only the study team can confirm", never "eligible".
How we built it
Hybrid inference, routed by data class
What the data is decides where AI may run. The web app, Android app and operator console use Firebase AI Logic's four inference modes, each for a reason:
- Public, heavy work →
ONLY_IN_CLOUD. In the operator console, Gemini turns public trial criteria into checklists once, for every patient. - Public questions →
PREFER_IN_CLOUD. "What is a CEA test?" contains no patient data. The cloud goes first, then the device, then a built-in glossary. The demo skips the cloud for these questions. - De-identified trial questions →
ONLY_ON_DEVICE, orPREFER_ON_DEVICEif she turns on cloud backup. Her privacy setting is the inference mode. If a device answer fails its checks and backup is on, that question can be retried once withONLY_IN_CLOUD. - Her words, report photos and visit summaries →
ONLY_ON_DEVICE. These tasks have no cloud path. - Matches, alerts, Door Check and Crossroads → no model. Fixed rules decide.
Trial questions go through four steps:
- Rules first. Questions that rules can settle never reach a model.
- A fail-closed validator. If an answer can't be verified, it becomes Unknown.
- An on-device audit. Each yes-or-no answer from a device model is checked again, one question at a time. The model must copy the patient's value, compare it, and then answer again.
- A visible source. The app shows whether rules, prepared answers, this device, a family device or the cloud handled each question.
An on-device yes-or-no answer is kept only if both readings agree:
$$ \text{final}(q)=\begin{cases} a_1(q), & a_1(q)=a_2(q) \ \text{Unknown}, & \text{otherwise} \end{cases} $$
With cloud backup on, an answer dropped by the audit can be retried once in the cloud and must pass the validator again.
One rules engine, three platforms
- Web: React PWA, with Gemini Nano through Firebase AI Logic.
- Android: Kotlin and Jetpack Compose, with Gemini Nano through Firebase AI Logic's hybrid modes (
firebase-ai-ondevice). On 30 November, it ran in the Android 16 emulator: Daily Pulse showed the red alert, and Rosa's low blood count affected the same 13 trials as on the web and iOS. The emulator has no Gemini Nano, so this tested the app and its rules, not its AI. - iOS: Swift and SwiftUI. firebase-ios-sdk 13 removed
HybridModel, so the app applies the same routing policy itself. It calls Apple's on-device Foundation Models directly and uses Firebase AI Logic'sGeminiLanguageModelfor cloud AI (iOS 27+).
The rules engine is written in TypeScript, Kotlin and Swift. Shared conformance tests hold all three to the same answers on every push. In the demo, the blood-count, Door Check and Crossroads numbers matched on the web and in the iOS simulator. The Android emulator showed the same 13 trials when Rosa's blood count dropped.
Firebase and Google Cloud
- App Check is enforced for AI Logic and callable functions. Firestore enforcement is written in Terraform but not applied yet.
- Authentication gives every demo its own anonymous user. Accounts are optional.
- Cloud Firestore stores trial data, plus health data encrypted on the device first. Security rules stop users from reading each other's data.
- Remote Config sets model names and limits, and can switch off cloud backup.
- Cloud Functions and Cloud KMS import, validate, sign and serve the trial list. The functions run no AI.
- Cloud Messaging sends family alerts that say only "Inclusion has an update".
- Firebase Hosting, Terraform and GitHub Actions handle hosting, infrastructure, testing and deployment.
What is real, and what is simulated
- Real: the trials, rules engine and encryption. In the video, Daily Pulse and the phone's trial-check excerpt use Apple's real on-device model in the iOS simulator. A local web build shows real cloud AI: 123 Gemini calls with no errors, handling 610 questions. That scene plays at 20× speed.
- Synthetic or simulated: the patients, records, portal, clinic and family laptop.
- Prepared in advance: 583 of Rosa's trial answers came from Gemini Nano before the audit existed, so the safety results below don't cover them. They expire as dates change.
- Not shown or tested: the Android app is implemented but isn't in the video. Cloud AI hasn't been confirmed end to end on Android or iOS. Neither phone app has been tested on a physical phone with on-device AI. Cloud accuracy hasn't been measured.
The cloud backup starts on in synthetic demos and off in real accounts.
Challenges we ran into
Our own tests found a safety problem. On 20 November, Gemini Nano in Chrome gave unsafe answers to 12 of 141 questions (8.5%). Unsafe means false reassurance: showing that a requirement was met when it wasn't, or wasn't known. Our limit was 5%. Eleven of the 12 mistakes involved numbers: thresholds, "more than" versus "at least", units or dates.
Asking the same question again helped least, because the model repeated its own arithmetic mistakes. We compared five designs, then combined rules first with a stricter on-device audit. On 25 November, the full app pipeline gave 0 unsafe answers out of 141 and 0 wrong exclusions.
Zero mistakes in a small test doesn't prove zero risk. The upper end of the 95% Wilson interval is:
$$ p_{\text{upper}}=\frac{z^2}{n+z^2}=\frac{1.96^2}{141+1.96^2}\approx 2.7\% $$
The trade-off: agreement was 63.8%, and about half the answers were Unknown. Those become questions for the care team.
The questions are synthetic and were labelled by the author, not by clinicians. The two runs used different Chrome versions, and Nano's answers vary between runs. The result doesn't cover prepared answers, cloud AI or phones. Apple's on-device model, tested on a Mac through the iOS app's code, gave 1 unsafe answer out of 141 (0.7%).
Other challenges:
- The iOS SDK changed. After
HybridModelwas removed, we put every iOS model call behind one adapter. A test fails if a model session is opened anywhere else. - The Android app passed CI but crashed when opened. Startup code used Daily Pulse before it had been created. Unit tests replaced that code, and CI never opened the app. We found the crash by running the app in an emulator, then fixed the startup order before the deadline. Passing tests doesn't prove an app opens.
- A trial-list update once emptied the demo. Prepared answers were tied to one version of the list. They now depend on each question's text and the patient's exact summary, so a list update no longer breaks them. They still expire when the summary changes.
- The AI budget ran out. A spending cap blocked cloud calls. Failed calls now leave trial questions open instead of guessing, and reusing compiled trials keeps costs down.
Accomplishments that we're proud of
- Hybrid inference is part of the product. The data decides where AI may run, and the patient's privacy setting selects the inference mode.
- Families can share on-device AI, so a phone without a model can get help before any cloud model is considered.
- Inclusion can warn about trials a planned drug would close, before the first dose.
- One rules engine works across web, Android and iOS, checked by shared tests. Locally, 1,932 web, console, functions, shared-package and evaluation tests pass. CI also runs Firestore, Android and iOS tests.
- We published our unflattering results too, including failed designs, unknown answers and models we haven't measured: see the full evaluation.
What we learned
- "Device or cloud?" is the wrong first question. Ask what the data is, who may see it and whether AI should decide at all.
- In healthcare, "I don't know" is a feature. An honest Unknown is safer than a confident guess.
- Repeating a question isn't checking the answer. Making the model copy and compare the actual value worked better than asking the same question again.
- Run the app as well as its tests. Our Android crash showed why both matter.
- Privacy should be visible. A ledger people can inspect is stronger than a promise.
- Hybrid AI can be affordable. Patient-side AI is designed to run mainly on devices people already own. Our main cloud AI cost is preparing trials once, so it grows mostly with the number of trials. Optional cloud backup adds to that cost.
What's next for Inclusion
- Clinical review of the triage rules and Door Check before any patient uses them. Inclusion is a prototype, not a medical device or medical advice.
- Testing Android and iOS on physical phones, including on-device and cloud AI. We'll also measure cloud accuracy and add a CI test that opens the Android app.
- More cancers: colorectal, prostate and blood cancers.
- A sustainable model: free for patients, and ranking will never be for sale. One possible customer is oncology practices that receive symptom summaries patients approve and encrypt. Collecting electronic patient-reported outcomes is required, in phases, in CMS's Enhancing Oncology Model. There are no customers yet.
Built during the hackathon
This is a new project. The first commit was on 14 November 2026, during the submission period, and the public repository has the full commit history. We used AI coding assistants and open-source libraries. Third-party data and terms are listed in NOTICE.
Built With
- clinicaltrials.gov
- cloud-firestore
- cloud-functions
- cloud-kms
- fhir
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firebase-cloud-messaging
- firebase-hosting
- firebase-remote-config
- foundation-models
- gemini
- gemini-nano
- jetpack-compose
- kotlin
- react
- swift
- swiftui
- terraform
- typescript
- vite
- webrtc