@nikithaseelam/medtwin-agent
flwr new @nikithaseelam/medtwin-agentMedTwin Hospital Agents (Flower AgentApp)
Research prototype, not a medical device. Synthetic patients only.
A chain of agents runs one fracture patient's hospital case. A named clinician approves each step:
- Intake agent extracts facts from a synthetic Synthea FHIR record.
- Imaging agent reports the finding of a federated fracture model. It can never raise the model's confidence.
- Surgical debate: a patient-goals agent, a plate advocate and a nail advocate argue from the patient's own priorities (FHIR Goal resources: fast recovery, low cost, stable recovery). A judge builds a priority-by-priority table and never recommends. The surgeon decides.
- Care-plan agent drafts post-op measures. Any item that names a drug or dose is removed in code.
- Digital twin agent explains what-if recovery projections (illustrative multipliers).
Every chat message is one Flower run, and the case persists across the run series.
Usage
flwr chat # then /load . (or the Hub app spec) and send the commands below
admit DT-0429 # also DT-0512 (athlete) and DT-0733 (72, Medicare, osteoporosis) confirm Dr Lee # gate 2: diagnosis, then the surgical debate choose nail Dr Patel # gate 3: surgical plan, then the care-plan draft approve all Dr Lee # gate 4, or: approve 2 Dr Lee | reject 3 Dr Lee | edit 4 Dr Lee: <text> whatif smoker=no age=70 status | help
Configuration
-
Run config model (default dedicated/flowerai/Kimi-K2.7-Code-1OUHWL, the Nebius Token Factory model for the Flower hackathon). The MEDTWIN_FLOWER_MODEL environment variable overrides it.
-
The agents call the model endpoint that the Flower runtime provides, so the app holds no API key. To use Token Factory on a local SuperLink, set these variables before starting it:
export FLWR_MODEL_API_ENDPOINT="https://api.tokenfactory.tf-ca1.nebius.com/v1/responses" export FLWR_MODEL_API_KEY="<token-factory-key>" flower-superlink --insecure -
If the model is unreachable or returns invalid JSON, each agent falls back to a deterministic answer built only from the patient twin, and marks its output offline.
-
data/finding.json holds the finding of the clinician-approved federated model (gate 1), exported by the main MedTwin project. The federated training itself is a separate Flower ServerApp/ClientApp.
Data
The patient records are hand-written, Synthea-format FHIR bundles. They are synthetic, not real people. The imaging finding comes from a model trained on FractureMNIST3D (non-commercial licence). Only the model's output is included, not any images.