@talibdev/flower-hackathon
flwr new @talibdev/flower-hackathonThe Referee
A safe multi-agent hand-off demo on Flower — The Referee combined with teammate rare-disease research agents from StellaVadis/raredisease.
Pipeline:
- Reader finds a (fake) patient chart and shows where each fact came from.
- Research (optional, --research; on by default on Flower Hub): Agent A (evidence packet) → Agent B (clinical reasoning). Optional Consensus.app paper search when CONSENSUS_API_KEY is set (local). Hub Output shows a short judge card; full Research is in Logs.
- Writer turns chart + research into a plain-English hand-off summary — a prompt asks for no identifiers, but that is not a safety control.
- Referee inspects the outgoing summary and returns PASS, BLOCK, or ESCALATE when it spots a patient identifier (replaces raredisease Agent C for identifier privacy). A human (or voice edit) clears the leak.
No real patient data. Demo fixtures live in flower_hackathon/data/patients.py. --chat also loads a curated extract of NHS England’s synthetic clinical notes (NHSEDataScience/synthetic_clinical_notes) as patients H001… — not live EHR. NHS numbers in-repo are official dummy test numbers only.
Setup
uv sync
First --chat voice run downloads Whisper base (~140 MB). macOS may ask for Microphone permission. After each mic capture you get Use this? [Y/n/type again] so a bad transcript (e.g. Alanturner) is not applied. If the mic fails, type instead — the demo still works.
No API key needed for the Track 2 Writer. config.py points at the shared endpoint by default; provider.py only demands a key when the endpoint is Flower's own.
To use a different endpoint:
export FLWR_MODEL_API_ENDPOINT='http://134.199.193.245:8001/v1/responses'
export FLWR_MODEL='/models/Kimi-K2.7-Code'
Two of the Track 2 endpoints are open (Qwen3.5 397B and Kimi-K2.7-Code); the GLM and MiniMax ones return 401 without a key from Slack.
Doctor chat (the impressive demo)
Search by name, see sources, get a summary, let the Referee catch a leak, then fix it by voice:
uv run referee-demo --chat
Stage script (~3 minutes):
- Say or type Alan Turing (Enter alone = microphone; confirm with Y if Heard looks right).
- Reader lists sources ([walk-in 12 Mar], obs, plan). Writer summarises.
- Referee BLOCKs — Grace Hopper’s NHS number hid in free text as a “direct line”.
- At edit>, say or type remove the nurse’s number (not a patient name). Confirm the transcript, then Referee runs again → PASS.
- Optional: search H001 or Judith Ada Wells to show richer NHS England–style synthetic notes.
- One-liner: Reader pulls synthetic clinical notes; Referee guards what leaves.
quit exits. SuperGrid has no microphone — voice is CLI-only.
Flag demos (still work)
uv run referee-demo --rigged
uv run referee-demo --clean
Optional rare-disease research before Writer (local = model-only sketch; SuperGrid can expose web_search / web_fetch):
uv run referee-demo --rigged --research
Single steps:
uv run referee-demo --reader P002
uv run referee-demo --writer P002
No model / no network:
uv run referee-demo --rigged --samples
Flower runtimes
Local SuperLink — export the endpoint in SuperLink's environment first:
export FLWR_MODEL_API_ENDPOINT='http://129.212.182.232:8001/v1/responses'
uv run flwr run . local --stream
uv run flwr run . local --stream -c 'demo.patient-id="P003"'
SuperGrid / Flower Hub — default model in pyproject.toml is already openai/gpt-5.6-sol (Track 2 paths like /models/Kimi-… fail with model_provider_error). Publish with uv run flwr app publish . after uv run flwr login supergrid.
uv run flwr run . supergrid --stream
uv run flwr run . supergrid --stream -c 'demo.patient-id="P002"'
uv run flwr run . supergrid --stream -c 'demo.research=true'
SuperLink connections live in ~/.flwr/config.toml; run config defaults live in [tool.flwr.app.config] in pyproject.toml.
Judge / federation wording: , .
The hand-off contract
Everything crossing an agent boundary is defined in flower_hackathon/contracts.py. Both tracks code against it:
| Stage | In | Out |
|---|---|---|
| Reader | patient_id: str | PatientRecord → sourced hand-off str |
| Research | chart text str (optional) | evidence sketch str |
| Writer | record text str (+ sketch) | summary str |
| Referee | any str | RefereeVerdict |
| Gate | RefereeVerdict + str | GateDecision |
from flower_hackathon.data import LEAK_SAMPLE from flower_hackathon.referee import review review(LEAK_SAMPLE) # BLOCK
Verdict rules: an NHS number is a BLOCK, a known patient name alone is an ESCALATE, anything else is a PASS.
Why the rigged run leaks
The Reader minimises at source: it drops the NAME and NHS NUMBER fields before handing anything to the Writer. Both runs work this way — the only variable is the data.
- --clean (P001, Ada Lovelace) — sources have no identifiers → summary PASS.
- --rigged / chat on P002 (Alan Turing) — the walk-in note names Grace Hopper and her NHS number as a “direct line” (943 476 5889). Field stripping cannot reach it. The Writer carries it; the Referee returns BLOCK.
That is the point of the demo. Minimising structured fields is good practice and it is not enough: identifiers hide in free text.
Layout
flower_hackathon/
contracts.py shared hand-off types
data/patients.py demo fixtures P001–P004 + merge HF cohort
data/hf_clinical_notes.json vendored synthetic notes (H001…)
data/hf_loader.py load HF extract offline
agent.py AgentApp entry point
config.py run config helpers
local_session.py AgentSession for stdin runs
reader.py Reader + find_patient
writer.py Writer + revise_summary
research.py optional rare-disease evidence sketch
referee.py Referee
gate.py human gate
voice.py mic listen + macOS say (CLI only)
demo.py --clean / --rigged / --chat / --research
pipeline.py Reader -> (Research) -> Writer -> Referee
Two hosts, one pipeline
run_pipeline() takes an AgentSession, so it runs unchanged in two places:
- Demo / --chat — in-process LocalAgentSession. Has stdin + mic.
- AgentApp — SuperLink / SuperGrid task. No stdin → auto_reject. No voice.
memory-bank/ holds Cursor's working notes; it is not part of the app.