Skip to main content

Safety Architecture

Critical Constraint

The system is designed not to provide medical advice. This is a day-one requirement, not a preference, and it shapes every layer of the architecture. It has failed in practice: on 1 June 2026 the pilot gave a specific medication dose (see The June 2026 dose incident). The system is positioned as a search tool (zoektool), not a clinical decision support system; this distinction is load-bearing for both medical-ethics duty of care and EU regulatory classification (see EU AI Act Compliance).

The June 2026 dose incident​

This section is the canonical record of the project's known medical-advice failures (a first dose incident, and the wider audit findings below). Other pages link here.

What happened. On 1 June 2026, during a live demonstration to the graduation jury on the pilot system's public web chat, the system gave a specific ibuprofen dose for a child. The question had been recognised as a request for medical advice, but the brochure-based dosing path overrode the refusal. A second juror reported receiving advice about a procedure. The logs for that answer could not be recovered; the most likely match (bowel-preparation medication instructions for a colonoscopy) was reproduced the next day, 2 June 2026.

Background. The system's day-one rule was that it must not give medical advice. On 14 May 2026 a design decision (ADR-0062, now superseded) relaxed that rule: dosing information was allowed when it came from the hospital's validated brochures.

Scope: the demonstration and production. An audit of the pilot's stored conversations on 1 June 2026 found that the dosing path had been answering dosing questions on the pilot since 15 May 2026 (with a gap from 18 to 28 May):

  • 78 dosing answers across 24 sessions, 46 of them to anonymous (not logged-in) users, including 6 insulin self-dosing answers;
  • about 15 of these answers gave a dose for an age outside the brochure's weight table, so the dose was not supported by the source;
  • 11 symptom-interpretation answers (web chat, 4 sessions) and 3 answers explaining possible causes of symptoms (voice channel).

Caveat. These counts come from the project's own audit. The logs of the demonstration itself were lost, so the record is the best available, not forensically complete.

Root cause. The policy relaxation itself, plus a grounding check that verified that a dose appeared in a source but not whether it applied to the person asking.

What changed afterwards​

DateChange
1 June 2026Refuse-and-link policy: questions asking for dosing, self-medication, diagnosis or treatment choice are refused, with a link to the relevant validated hospital brochure. The brochure-based dosing path was removed and an output check was added on chat; on the voice channel the full check runs before speech only from 4 June 2026. Recorded as ADR-0065 (12 June 2026), which supersedes ADR-0062.
2 June 2026Conversation and audit records are backed up so that incidents can be reconstructed (the demonstration's logs had been lost).
12 June 2026A "safety-floor" test suite (must-refuse and must-not-over-refuse cases) was added to the project's automated test pipeline, and a safety probe against the live pilot was added to the deployment script.
12 June 2026Process change: any change to safety policy now needs a written pre-mortem and a named human sign-off before work starts.
July 2026An adversarial audit of the safety architecture by the project found one weakened safeguard live on the pilot (a filter for medication instructions in procedure-preparation answers was not connected) and further defects. Among them: the automated pipeline had not run since mid-June (a billing lapse), some safety tests checked code that production no longer used, and the rollback triggered by a failed probe could not fire. The affected feature was switched off on 14 July 2026, and automatic rollback on a failed probe was added the same day. The fixes were merged and the pipeline ran again on 18 July 2026. A never-enabled extra classifier layer was removed on 17 July 2026.

Status wording​

The target is zero medical-advice incidents. That is a target, not an achievement.

Refusal is checked by the project's own automated tests and by a probe after each deployment (self-reported). These checks have had gaps:

  • they have existed since 12 June 2026;
  • the automated pipeline did not run from mid-June to 18 July 2026;
  • the pipeline cannot by itself block a change from being merged;
  • since 14 July 2026 a failed post-deployment probe rolls the deployment back automatically;
  • no independent audit has been carried out.

The page was first written in spring 2026 and last revised in October 2026.

The safety imperative​

Operating an AI system in the healthcare domain carries asymmetric risk. The cost function is non-linear: a poor product recommendation costs minutes; a mis-stated dosage can cost a life. Four failure classes drive the design:

FailureMechanismRegulatory consequence
Delayed careA patient receives reassuring-sounding information about symptoms that warrant urgent assessment, and defers contacting a clinician.Possible breach of duty of care; tort exposure under Belgian medical-liability law.
Mis-directionIncorrect department or doctor information sends a patient to the wrong specialist.Service-quality complaint; reputational.
Implicit adviceA response uses imperative ("you should take..."), declarative ("this condition requires..."), or dosage language that a layperson reads as instruction.Possible MDR (Medical Device Regulation, Regulation (EU) 2017/745) re-classification as software-as-a-medical-device, requiring CE marking.
Liability accretionThe hospital, as the data controller and channel operator, bears legal responsibility for content delivered through its digital surfaces under both general tort law and sector-specific regulation.Direct hospital exposure independent of vendor liability.

The pilot answers these with defense in depth — the principle that no single mechanism is trusted to be correct on its own — adapted to the LLM-application threat model documented in the OWASP LLM Top 10, in particular LLM01 (prompt injection), LLM06 (sensitive information disclosure), and LLM09 (over-reliance). The OWASP framing maps the technical controls to attacker capabilities rather than hand-waving "best practices"; the layered architecture below is the concrete realisation.

Multi-layer architecture​

The layers are designed to be independent: each is a separate component, can be switched on or off on its own, and has its own regression tests. The independence requirement is intentional — a coupled stack collapses to its weakest link, and OWASP LLM01 (prompt injection) attacks specifically target single-point-of-trust designs.

Layer 1: intent classification guard​

The voice channel has an equivalent pre-filter.

The first line of defence operates before any retrieval or generation. The intent classifier (Tier 2 model) analyses every incoming query and assigns one of twenty intent categories. Four trigger an immediate block: medical advice, off-topic, other hospital, and vague input. The other intents proceed to retrieval and generation, or to the dedicated lanes described below.

Trade-offs​

Alternative consideredWhy rejected
Single regex layer (no LLM classifier)Regex is fast (sub-millisecond) but cannot resolve the lexical ambiguity that drives most medical-advice slips. "Hoe wordt migraine behandeld?" (third-person passive, navigational) and "Behandel ik migraine?" (first-person imperative, advice-seeking) differ by two phonemes and are syntactically very close; only an LLM with semantic context distinguishes the two reliably. We keep the regex (Layer 3) as a complement, not a replacement.
Single LLM safety judge (no early classifier)A single late-stage judge means every benign query pays the LLM-judge latency tax (~500–800 ms) and the unsafe queries already received compute on retrieval + generation that they were never going to use. Early classification short-circuits both costs.
Block all symptom-mentioning queries unconditionallyFalse-positive rate would be catastrophic. "Waar is de afdeling cardiologie?" mentions a condition class but is purely navigational. Patients would be funnelled to the helpdesk for routine wayfinding.

Safety message​

When medical advice is detected, the system returns a standardised Dutch message:

"Ik kan geen medisch advies geven. Voor medische vragen kunt u contact opnemen met uw huisarts of met ZOL via 089 32 50 50. Ik help u graag met informatie over onze afdelingen, artsen, en diensten."

(I cannot provide medical advice. For medical questions, contact your general practitioner or ZOL at 089 32 50 50. I am happy to help with information about our departments, doctors, and services.)

The message: states the limitation explicitly; redirects to a clinician (general practitioner first, hospital phone as fallback); offers continued help on informational queries; cites the hospital's main phone number as a verifiable escape hatch. Per GDPR Art. 22 (automated decision-making), the redirect is structured as a helpful re-route rather than a denial of service — the user is never left without a path forward.

After the incident described in The June 2026 dose incident, the medical-advice policy was tightened to refuse and link: questions asking for dosing, self-medication, diagnosis or treatment choice are refused, with a link to the relevant validated hospital brochure. The brochure-based dosing path that had overridden the refusal was removed, and an output check was added on both the chat and voice channels (recorded as ADR-0065, 12 June 2026, which supersedes ADR-0062).

The patient is not given a dose. They are pointed to the document they are entitled to read, plus the clinician to consult.

The output check combines two parts:

  • A deterministic pattern check that catches numeric dose claims.
  • A small language-model classifier, run only on medical-adjacent intents, that catches prose failures a pattern cannot: causation ("X causes Y"), diagnosis, and false reassurance ("many patients in your situation find that…"). It does not run on navigational traffic.

The lesson recorded in the design review is that a citation is necessary but not sufficient for grounding: the earlier audit checked that a dose appeared in a cited source, not that it applied to the person asking.

Input-side intent lanes (June 2026)​

A new class of control entered the architecture in June 2026: input-side intent lanes that fire before retrieval, parallel to Layer 1, short-circuiting generation entirely for a small, well-defined set of high-stakes inputs. Each lane follows the same three-part shape:

deterministic floor → narrow nano classifier → localised deterministic renderer
(patterned inputs) (prose-only, fail-safe) (no LLM in the output path)

The renderer is fully deterministic, so the response on these lanes is designed not to drift into advice. Two lanes are live:

LaneFires onRoutes to
Emergency escalationAcute red-flag presentations (chest pain, stroke signs, self-harm, …)Immediate escalation to emergency services / helpline, never a brochure lookup
Sensitive-identity correctionA protected identity (sexual orientation / gender identity) framed as an illness to be curedA non-pathologising correction → Psychologie / Seksuologie / Gendercentrum — never psychiatry-by-default; never names a doctor

The design principle across both: deterministic where the input is patterned, a tiny classifier only where the input is prose, and always failing in the safe direction. The classifiers are gated narrowly (the identity classifier only runs when the query mentions a protected identity at all) and the floors fire only on grammatical predication, not mere co-occurrence — "I'm gay and I have an anxiety disorder" must not trip the identity lane. See Sensitive-Identity Correction for the full lane, including the self-vs-other classifier and the co-occurrence negatives that gate it.

Both lanes can be switched on and off independently and run on both the chat and voice channels.

Layer 2: post-generation regex safety validation​

Even when the intent is classified as safe, the generated response itself could inadvertently contain medical-advice language — either because the retrieval surfaced a chunk that was permissive or because the generation drifted from the system prompt. Layer 2 scans the generated text for Dutch medical-advice patterns using compiled regular expressions:

Pattern categoryExamples
Dosage language"neem 2 tabletten", "dosering", "mg per dag", "maximaal 2 capsules"
Treatment directives"u moet", "u dient", "het is noodzakelijk"
Diagnostic language"u heeft waarschijnlijk", "dit wijst op", "diagnose"
Medication references"medicatie", "voorschrift", "bijwerkingen"
Medication dosage adjustment"verhoog uw dosis", "verlaag uw dosis"
Urgency language"ga onmiddellijk naar", "bel direct", "spoedeisend"

Patterns were developed to capture the linguistic markers of medical advice in Flemish Dutch. The validation is enabled by default; for a hospital system, safety is designed to be opt-out, never opt-in.

Contextual sensitivity

Some terms (such as "medicatie") appear in legitimate navigational content — "Bring a list of your current medication to your appointment". The regex set therefore matches on phrasings that combine a medication noun with an imperative verb form, rather than on noun mentions alone. False-positive rate is monitored as a deployment KPI (target < 5 %).

Why regex and LLM, not just LLM​

A latency / coverage trade-off, made explicit:

Optionp50 latencyRecall on paraphrased adviceCost per query
Regex only< 1 msHigh on canonical phrasings; misses paraphrasesEffectively zero
LLM-as-judge only500–800 msHigh on paraphrases; depends on prompt rigor$0.0005–0.002
Regex + LLM-as-judge< 1 ms (most queries) + 500–800 ms when LLM firesHighest combined recallSum of both

Regex catches the high-volume, canonical phrasings cheaply; the LLM judge catches paraphrased and subtle advisory language that pattern matching misses. Running both costs essentially the same as running just the judge, because the regex tier completes long before the LLM call returns.

Layer 2b: LLM-as-judge safety validation​

A second-pass safety review where an LLM (the Tier 2 model) judges whether the generated response contains medical advice. This catches paraphrased and subtle advisory language that regex pattern matching cannot reliably detect — for example, "many patients in your situation find that ..." which avoids any directive vocabulary but functions as advice.

AspectDetail
ModelTier 2 (Anthropic Claude 3 / OpenAI GPT-4.1-mini, configurable)
ModeAsync, fail-closed — timeout or API error blocks the response as a safety precaution
DefaultEnabled on voice; configurable on the text channel
ConfigurableCan be toggled by an administrator for demos and incident response

Removed: external guardrails classifier (July 2026)​

An optional extra classifier layer from an external model family was designed and built in early 2026 but was never enabled in production. It was removed on 17 July 2026. It is not part of the current safety architecture. The fail-closed principle described above applies to the language-model judge: under a transient outage the system degrades to a more restrictive posture rather than a more permissive one.

LLM judge prompt rigor​

The judge uses a strict classification prompt that distinguishes six violation categories: dosage information, specific medication names presented as treatment options, diagnostic statements, treatment plans, triage advice, and self-care instructions. A critical prompt rule is that a disclaimer like "raadpleeg uw arts" does NOT make medical content safe — the judge flags dosage information even when a disclaimer is present, because users read the dose and may ignore the disclaimer.

Layer 3: quality gate​

See Quality Evaluation.

The quality gate serves a dual purpose: it measures response quality and acts as a confidence check. Responses below the calibrated similarity threshold (0.45 on the current embedding model — see ADR-0048) are more likely to contain hallucinated or poorly grounded content. Low-confidence responses are replaced with a safe fallback that acknowledges the question without attempting an answer.

The quality gate is the explicit over-reliance mitigation per OWASP LLM09: rather than allowing the LLM to attempt every question regardless of grounding, the gate forces the system to admit it doesn't know.

Layer 4: AI disclosure and notices​

The backend does not append a medical disclaimer to each answer. An earlier design did, but that function did nothing from April 2026 and was removed in July 2026. What exists today:

  • the web chat shows a standing notice that it is an AI assistant and gives no medical advice;
  • voice calls open with a spoken AI disclosure;
  • since 18 July 2026 (merged), every answer the backend returns also carries a separate AI-disclosure field in five languages; the web chat does not display that field.

None of these has a dated verification on the live pilot. A notice is a transparency measure, not a safety control: it does not stop an answer from containing advice.

Safety targets​

MetricTargetMonitoring
Medical-advice incidentsTarget: zero (not achieved: see The June 2026 dose incident)Automated pattern detection, the project's safety-floor tests, a live probe after each deployment, manual audit
Intent classification accuracy> 95 % (target)Evaluation against a labelled test set (the project's own, self-reported)
Safety filter false-positive rate< 5 % (target)User feedback analysis

The target is zero medical-advice incidents. Refusal is checked by the project's own automated tests and by a probe after each deployment (self-reported; these checks have had gaps, described above).

Defense-in-depth verification matrix​

The defense-in-depth principle: each layer operates independently, and the failure of any single layer does not compromise overall safety. The table below verifies the property by walking representative scenarios:

ScenarioLayer 1Layer 2 (Regex)Layer 2b (LLM judge)Layer 3Layer 4Outcome
Clear medical advice queryBlocks--------Safe
Safe query, unsafe responsePassesBlocks------Safe
Subtle advisory languagePassesPassesBlocks----Safe
Safe query, low confidencePassesPassesPassesBlocks--Safe
Safe query, good responsePassesPassesPassesPassesNotice shownSafe
Classifier + regex failFailsFailsCatchesCatchesNotice shownSafe
All filters failFailsFailsFailsFailsNotice shownNot mitigated: advice may reach the user

In the worst case — where intent classification misses a medical-advice query, both regex and LLM validation fail, and the quality gate scores the response above threshold — no further control stops the answer; the AI notice is a transparency measure, not a safeguard against advice. The June 2026 incident shows that such a failure can occur in practice, which is why the upstream defences and their tests matter.

Regulatory mapping​

The table below maps the safety architecture to the relevant European frameworks. It is the project team's own mapping, not legal advice or a conformity finding:

RegulationSpecific provisionHow the architecture addresses it
EU AI Act (Regulation (EU) 2024/1689)Art. 50 (transparency obligations for AI interacting with natural persons); Art. 13 (transparency); Art. 14 (human oversight)Design intent: a standing AI notice in the chat interface, a spoken AI disclosure on voice calls, a separate AI-disclosure field in backend answers, and a helpdesk fallback as the human-oversight path. None of these has a dated verification on the live pilot (see EU AI Act Compliance)
Medical Device Regulation (Regulation (EU) 2017/745)Art. 2(1) (definition of medical device); Annex VIII Rule 11 (software classification)System explicitly does NOT provide clinical decisions — positioned as an information retrieval tool (zoektool); see classification analysis in EU AI Act Compliance
GDPR (Regulation (EU) 2016/679)Art. 5 (principles); Art. 25 (data protection by design); Art. 32 (security of processing)PII detection; audit logging; data minimisation (the system indexes no patient records; users may still type health-related text into queries); see DPIA

The decision to position the system as an information retrieval tool rather than a clinical decision support system is the load-bearing classification: it is intended to avoid MDR re-classification as software-as-a-medical-device. This is the project's own assessment; it has not been confirmed by a legal opinion.

See GDPR (Regulation (EU) 2016/679) for canonical text. See EU AI Act (Regulation (EU) 2024/1689) for canonical text. See EU MDR (Regulation (EU) 2017/745) for canonical text.

Voice channel — same invariants, different surface​

The voice channel pursues the same no-medical-advice requirement through a structurally similar but stage-merged architecture: pre-LLM regex pre-filter → agentic LLM with tool-grounded retrieval → post-LLM regex safety post-filter → spoken AI disclosure at the start of the call, and the voice answer shaper's own per-language disclaimer step (see Voice Safety Architecture). See Voice Safety Architecture for the full detail; the high-level mapping is:

Text-channel layerVoice-channel equivalent
Layer 1: intent classificationA pre-filter that classifies the utterance before the language model runs (the safety-refusal class is the safety-critical branch)
Layer 2 + 2b: regex + LLM judgeCombined into the agentic orchestrator's tool-grounded retrieval (ADR-0051) plus a post-LLM regex post-filter
Layer 3: quality gateRAG retrieval's found=False consecutive count, escalating to helpdesk after two strikes
Layer 4: AI disclosureSpoken AI disclosure at the start of the call; the voice answer shaper's own disclaimer step

References​

  • @owasp_llm_top10 — LLM01 (prompt injection), LLM06 (sensitive information disclosure), LLM09 (over-reliance) framings used throughout this page.
  • ADR-0036 — adversarial-input hardening (perplexity-based anomaly detection, LLM-as-judge, retraction enforcement).
  • ADR-0049 / ADR-0051 — voice-channel orchestrator lineage.
  • Voice Safety Architecture — voice-channel safety detail.
  • DPIA — GDPR Art. 35 risk assessment.
  • EU AI Act Compliance — the project's own AI Act classification assessment.
  • Amann, J., Blasimme, A., Vayena, E., Frey, D., & Madai, V. I. (2020). Explainability for artificial intelligence in healthcare: A multidisciplinary perspective. BMC Medical Informatics and Decision Making, 20, 310. https://doi.org/10.1186/s12911-020-01332-6