When a patient asks about their health record, the AI needs the right parts of that record. It must never see another patient’s data, large records still have to fit, and the answer should not take long. This page explains the approach the UW CIRG & WAHS team chose and the evidence behind it.
Updated November 2026 · Written for the whole project team · Developers: Engine reference →
Key decisions
Condense the record first. The engine shrinks the patient’s record into a short, numbered summary and sends it to the model with the question, in one call.
A small middle service does that work. The WAHS engine sits between the WAHS app and the model server, so the app stays simple and the model can be swapped.
One model for the pilot: Gemma 4 12B. It scored within 1.6 points of the largest model tested and gave the fewest unsafe answers.
90 to 99%
Reduction in record size after the engine condenses it.
67.2 → 80.5
Gemma 4 12B score out of 100, without and with the engine. Unsafe answers fell from 7 to 2 of 36.
2.5 to 4 s
Median wait for a follow-up answer on the shared GPU server in testing.
A question passes through three components. Each can change without touching the other two.
CIRG · patient-facing app
WAHS app
Shows the chat and the record.
Keeps the conversation in the browser.
Sends each question through its own server, never straight to the model.
→↓
question and sign-in
This project · middle service
WAHS engine
Fetches the signed-in patient’s current record.
Condenses it and adds clinical knowledge for the question.
Returns the answer with links to source records.
Reads from the record store using the patient’s own sign-in. The engine has no access of its own, so it can only ever receive that patient’s records.
→↓
condensed chart and question
UW CIRG GPU server · or an agency’s own
Model server
Runs the open-weight model, Gemma 4 12B by default.
Keeps nothing between requests.
Can be any server that speaks the standard OpenAI chat format.
The app does not call the model directly, for three reasons. The model server cannot check who is asking. A raw record is too large: on big charts the start of the record was cut off and answers scored 0 to 2.8 out of 100. And the answer would carry no links back to source records.
Worked example
Tracing “What are my diabetes labs?” through six steps
Steps 2 to 5 happen inside the engine and take about a tenth of a second. Almost all of the wait is the model writing its answer.
The app sends the question.
It goes with the conversation so far and the patient’s sign-in token. The app does not send the record itself.
The engine fetches the patient’s current record. Checked every question
It asks the record store with the patient’s own token and checks whether anything changed. Unchanged data is reused from memory.
The engine condenses the record. Same for every question
The record shrinks by 90 to 99% into a numbered list. Allergies, active medications and active problems are kept first. Anything left out is counted in a note at the top, so nothing disappears silently.
The engine adds clinical knowledge for this question. Changes with the question
A short block is picked to match the question: which tests count as diabetes labs, and how this patient’s conditions, medications and labs connect.
The engine looks up relevant items that were left out. Only when needed
When the condensed chart had to drop items, the engine searches the full record for matches to the question and attaches the closest ones.
The model answers, and the answer streams back.
Each claim carries a number such as [12] that opens the exact source record in the app. If the record does not hold the answer, the model is told to say so.
The three parts of the model input
Part 1 · The condensed chart · same for every question
[1] Patient summary
[2] Completeness note: what, if anything, was left out
[4] Type 2 diabetes (active)
[12] HbA1c 7.8%
[14] eGFR 44
… more numbered entries
Part 2 · The conversation so far
Part 3 · For this question · changes each time
Diabetes labs include HbA1c, fasting glucose, eGFR and urine albumin.
Type 2 diabetes [4] is monitored by HbA1c 7.8% [12] and eGFR 44 [14].
Question: What are my diabetes labs?
Illustration only, not a patient record. Because Part 1 does not change between questions, the model server can reuse its work on it. That is why follow-up answers are faster than the first one.
Approaches compared
Condensation is the pilot default; note search and model queries build on it
A raw health record is far too large to hand to a small model. One multi-year test record is 18.4 MB, and real exports can reach 100 to 200 MB. The team compared three ways to give the model what it needs. They are not rivals: the second and third still need condensation.
Pilot default
1. Record condensation
Method
Shrink the whole record into a short numbered summary and send it with the question in one call.
Strengths
Speed, and a simple privacy boundary: the model only ever sees one patient’s summary.
Limitations
At small sizes, older labs and long notes are left out and must be looked up.
Test result
Passed 65% of checks.
Tested · best overall
2. Condensation with note search
Method
Keep the condensed chart. For long notes, find the passages that match the question and add only those.
Strengths
Hospital and specialist notes of 4,000 to 14,000 tokens, and very large records.
Limitations
One more step per question, so answers take a little longer.
Test result
Passed 76% of checks, the highest of the three.
Tested · needs a large model
3. Model-written record queries
Method
The model writes its own searches against the record store, then reads what comes back.
Strengths
Huge records, when the model is strong enough to write correct medical codes.
Limitations
Smaller models pick wrong codes. It needs guardrails on every search and takes several steps.
Test result
Passed 61% overall, but 96% on the largest model.
Results are from 384 test runs on four models. An answer passes only if it meets every automated check: the expected clinical facts, the size limit and the citation rules. Sending the raw record with no engine passed 19% and leaked private items in 12 of 12 sharing tests. Retrieval and portability report ↗
Test evidence
Five findings that support the design
Tested on 18 record bundles from 10 patients, including synthetic multi-clinic records and real de-identified hospital records.
Condensing removes 90 to 99% of a record and keeps the safety core
Condensing removed 90 to 99.4% of the size and kept the full safety core: allergies, active medications, active problems and implants. An 18.4 MB record fits in 8,000 tokens, and every omitted item is counted.
The engine looks up omitted items before calling the model
This covers the case where the answer sits in a part of the record that was left out. On very small summaries, the lookup raised Gemma 4 12B from 47.0 to 68.2 out of 100, with no unsafe answers.
Added clinical knowledge helps models of 4B and larger
Small models do not know lab codes or drug interactions. Adding clinical rules improved accuracy. Adding the patient’s own links between conditions, medications and labs cut unsafe answers by 43 to 71%.
An overfull model silently drops the start of the chart
This is why the engine condenses the record instead of sending a very large chart. On a shared GPU with a 16k limit, sending 32k to 128k of chart text erased allergies and medications, and scores fell to 0 to 2.8 out of 100.
Every claim must cite a source record, and the model must say when the record has no answer. In tests built to pressure it into guessing, Gemma 4 12B gave 2 unsafe answers in 36 and no made-up citations.
Gemma 4 12B is the pilot model; the engine improves seven of nine models
Nine open-weight models answered the same 36 clinical questions, first with the condensed chart alone and then through the full engine. Two judge models graded the answers without knowing which setup produced them.
Score out of 100, before and after adding the engine
It is within 1.6 points of the 26B model and gave the fewest unsafe answers of any setup.
The engine improves most models
Seven of nine scored higher through the engine, and eight of nine gave fewer unsafe answers.
Models below 4B are not sufficient
The 3B model got worse with more to read. Treat 4B (Gemma 4 E4B) as the minimum.
The score combines the judges’ grades, weighted toward accuracy and completeness, with points taken off for unsafe answers and citation errors. A middle setup (chart plus clinical rules, without the patient links) and the full table are in the nine-model report ↗.
Design clarifications
Nine points on sessions, data handling and deployment
These points were raised in project meetings. Full detail is in the Engine reference.
The chat session is kept in the patient’s browser
On each turn the app sends the conversation so far. Neither the engine nor the model server keeps a copy, and there is no session ID. Starting a new chat clears the browser’s copy.
The engine holds the condensed chart in memory to save time, tied to the signed-in patient, and loses it on restart. Before real records are used, prompt logging on the model server is turned off.
The KV cache is a speed feature and cannot cross patients
The KV cache is the model’s short-term memory of text it has just read. It is not the knowledge base (KB). The model skips re-reading only when a new request starts with exactly the same text. Every request starts with one patient’s own chart, so another patient’s request cannot match it.
The chart is rebuilt when the record store reports a change
The engine checks the record store on every question. When the store reports that part of the record has changed, only that part is fetched again and the chart is condensed again. This takes about a tenth of a second.
Chart size is a setting, about 8,000 tokens by default
The size is a setting called the token budget. A token is about three-quarters of a word. The default is about 8,000 tokens, and the app can request a different size. It does not change with the question. Smaller charts are faster but leave more out.
Clinical knowledge is selected for each question
The engine selects clinical guidelines and patient graph links that match the question in the Layer-3 suffix without a hardcoded 800-token cap. When tests compared chart sizes, the questions and the knowledge base were held fixed so that size was the only thing changing.
Med Agent Hub and the WAHS engine share the same core code
Med Agent Hub is the research workbench where approaches are built and benchmarked. The WAHS engine is a small service holding only what WAHS needs to run. Both use the same core code, so a result measured in the Hub applies to the engine.
The model and the front end can be replaced
Both sides of the engine use the standard OpenAI chat format. Pointing it at a different model or server is a configuration change, tested with no code edits. An agency that must use its own approved model can do so.
The pilot runs on a 35 GB slice of a shared GPU
The GPU is a shared UW CIRG server. How many people can chat at once depends on a server setting that trades speed against memory. That setting is being tuned for the pilot.
Project status
The engine is built and verified in the development setup
The engine runs as its own small service.
It reads records only with the patient’s sign-in.
The web app and a mobile front end both reach it through their own servers, in the development setup.
Automated checks for cross-patient leaks and stale charts pass.
The three approaches were compared across 384 runs.
Two-stage monotonic condensation, longitudinal [TEMPORAL DIGEST] synthesis, the patient relationship graph, and how the Layer-3 question block is built.
Full system architecture diagram, foundational standards links, 900-cell H200 benchmark readout, and 27 code-level audit findings across wahs_core, wahs_engine, and connected BFFs.