From 15ec830038f001aa9409c370efeb469eb388b842 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 14 Sep 2026 18:30:28 +0200 Subject: [PATCH] fix: each pool batch names what the category already holds, so no batch repeats the last Batches three onwards reuse the first batches' snippets, and an identical request came back with the identical list: every category stopped at exactly 40 of its quota. The list of what is covered makes each request, and each answer, new. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016fZGJNyDvERbMgS2Uc2msP --- src/utils/clinicalPromptPool.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/clinicalPromptPool.js b/src/utils/clinicalPromptPool.js index 6a324d2e..5d4c29ab 100644 --- a/src/utils/clinicalPromptPool.js +++ b/src/utils/clinicalPromptPool.js @@ -355,12 +355,21 @@ function createClinicalPromptPool(opts) { var sourceText = batchSnippets.map(function(s, idx) { return '[' + (idx + 1) + '] ' + s.title + (s.page ? ', page ' + s.page : '') + '\n' + clip(s.excerpt, 700); }).join('\n\n'); + // Every batch after the first names what the category already holds. + // Batches three onwards reuse the first batches' snippets (there are + // 36 for 18 a batch), and an identical request came back with the + // identical list — every category stopped at exactly 40 — so the list + // of what is covered is what makes each request, and each answer, new. + var covered = categoryExamples.map(function(ex) { return ex.label; }).filter(Boolean); + var coveredNote = covered.length + ? '\n\nAlready covered for this category — ask about something else: ' + covered.join('; ') + '.' + : ''; var ai = await opts.callAI([ { role: 'system', content: 'Write starter questions for a pediatric clinical assistant. They are what a resident or a paediatrician would ask to learn something concrete about children — not a case, not a scenario, not a vignette. Use only the provided titles/snippets as inspiration; do not answer the questions and do not mention source names. Each question asks one definite thing with a definite answer: a mechanism (why a disease produces a finding, how a drug or a test works, what goes wrong in the physiology), a distinction (what separates two conditions that look alike, and why), a threshold or a number that matters in children (a dose, a cut-off, an age at which something changes), or the reason behind a rule of practice. Prefer pathophysiology wherever the source supports it. Name the disease, drug, organism, test or finding in the question itself, and keep it paediatric: an age group, a childhood disease, or a paediatric dose or value. Never open with a patient ("A 6-week-old with…", "A child presents…"), never invent findings, never ask "What is X?" alone. 10 to 30 words. Return strict JSON only: {"questions":[{"label":"2-5 word label","prompt":"question ending with ?","category":"' + item.category + '","age_band":"' + item.ageBands.join('|') + '","intent":"diagnosis|management|red_flags|differential|counseling|dosing|admission|discharge|review"}]}.' }, - { role: 'user', content: 'Category: ' + item.category + '\nAge bands: ' + item.ageBands.join(', ') + '\nIndexed pediatric source snippets:\n\n' + sourceText + '\n\nCreate 20 starter questions for this category, each a concrete thing to learn, mechanism first. Vary what is asked (why a finding happens, how a treatment works, what distinguishes two conditions, which number decides, why a rule exists) and the age group. Examples of the kind wanted: "Why does pyloric stenosis produce a hypochloraemic metabolic alkalosis, and why is the urine paradoxically acidic?", "How does a ductal-dependent lesion stay hidden until the duct closes, and what does prostaglandin E1 do?", "Why are infants under 3 months given broader empiric cover for fever than older children?" No scenarios.' } + { role: 'user', content: 'Category: ' + item.category + '\nAge bands: ' + item.ageBands.join(', ') + '\nIndexed pediatric source snippets:\n\n' + sourceText + '\n\nCreate 20 starter questions for this category, each a concrete thing to learn, mechanism first. Vary what is asked (why a finding happens, how a treatment works, what distinguishes two conditions, which number decides, why a rule exists) and the age group. Examples of the kind wanted: "Why does pyloric stenosis produce a hypochloraemic metabolic alkalosis, and why is the urine paradoxically acidic?", "How does a ductal-dependent lesion stay hidden until the duct closes, and what does prostaglandin E1 do?", "Why are infants under 3 months given broader empiric cover for fever than older children?" No scenarios.' + coveredNote } ], { model: chatModel || undefined, // The pool is a list, not a reasoning task: DeepSeek writes it