ADR-0057: Tenant-Scoped Prompt Addendums + Tenant-Agnostic Doctor-Profile Boost
Date: 2026-05-12 | Status: Accepted (shipped) | Related: ADR-0055 FAQ-Corpus Drift Prevention, ADR-0056 Chat Answer-Shape Typology
Context
On 2026-05-12 the project author reported a factual error: when asked whether a named doctor consults on Wednesday ("Is er raadpleging voor Dr. <Name> op woensdag?"), the system answered "geen raadpleging op woensdag" while the hospital's existing search tool correctly answered "Ja, woensdagvoormiddag." The corpus contained the canonical doctor profile page with a markdown schedule table:
| | MA | Di | WO | DO | VR | ZA |
| VM | RP2w | RP2w | RP2w | RP | RP2w | |
| NM | RP | | | | | |
The VM × WO cell is RP2w (bi-weekly consultation) — non-empty — so per the existing TABULAR DATA RULE the answer should be YES. The LLM still inverted the fact.
Two compounding root causes:
- Schedule-table parsing failure. The shared TABULAR DATA RULE has no abbreviation legend, no worked example for the hospital's doctor schedule format, and no guidance on reading both VM and NM rows. The LLM was guessing.
- Retrieval contamination. Our system cited
[1][2][3]— pulling the canonical doctor page, the "Arts Anders" interview profile, and a multi-doctor cardiology page. The existing search tool cited only the canonical profile. The thematic co-retrieval diluted the schedule signal in our cited chunks.
Decision
Ship two complementary fixes in one commit, each at the right layer of abstraction.
Layer 1 — Tenant-scoped prompt addendums (NEW pattern)
The doctor-schedule format (morning/afternoon rows by weekday, with consultation codes or empty cells) is specific to this hospital — other hospitals format schedules differently. A rule specific to this format should NOT live in the shared system-prompt template.
- A new schedule rule containing the abbreviation legend, a worked example and a counter-example.
- A new tenant-scoped registry mapping each tenant to its addendum text. Today only one tenant has an entry; new tenants register their own entries without touching the shared template.
- A helper called when the chat-channel system prompt is assembled, after the shared answer-shape rules. The voice path does NOT call this helper.
Layer 2 — Tenant-agnostic doctor-profile boost
The "Dr. <Name>" → canonical profile retrieval pattern generalises across every hospital website that follows the convention of putting the doctor's name in the document title.
Three code changes in the search service:
- Make the document title available to the boost functions on all three result paths (vector search, keyword search, keyword rescue).
- Add a pattern that recognises "Dr. <Name>" in the query (in nl/en/fr/it), capturing one to three capitalised name parts with accent tolerance.
- Add a boost that multiplies the chunk score by 1.50× when the chunk's document title starts with that doctor's name, wired into the existing metadata-boost step.
Boost factor calibration: 1.50 was chosen because:
- Strong enough to pull the canonical profile from rank 2-3 to rank 1.
- Not so strong it crushes other signals (campus boost is 1.10, conversation-context boost is 1.40, authority dampening can be 0.85).
- The same band as the existing pediatric booster pattern.
The architectural distinction
This ADR codifies a recurring decision: when a fix is corpus-format-specific, isolate it to the affected tenant; when a fix is convention-specific, generalize it across all tenants.
| Fix shape | Isolation surface | Example |
|---|---|---|
| Tenant-specific data format (table layout, abbreviation system, brand strings) | Tenant-scoped prompt addendum | The hospital's schedule table |
| Universal naming convention (doctor profile titles, common URL patterns) | Tenant-agnostic boost function | Doctor-title boost |
| Universal answer shape (procedure definition, comparison, decision tree) | Shared answer-shape rules | ADR-0056 |
| Tenant-specific FAQ / canned answer | Tenant overlay configuration | ADR-0055 surviving entries |
The principle: the layer of the system that owns the fix should be the SAME layer that owns the convention being matched. Hospital-specific data → tenant overlay. Universal convention → shared code.
Consequences
Positive
- No whack-a-mole for this tenant. Every future hospital-specific format quirk (campus abbreviations, brand phrasings) lands in the same tenant-scoped registry.
- Zero impact on other tenants. A new hospital onboarded tomorrow does NOT inherit this hospital's schedule-table rule. Their tenant slug defaults to empty addendum unless they register one.
- Doctor-profile boost generalises. Any tenant whose doctor pages put the doctor's name in the title gets the boost for free.
Negative / trade-offs
- Slightly larger chat prompt for this tenant. The schedule rule adds ~30 lines / ~300 tokens per chat query. ~$0.0003 at GPT-4.1-mini pricing. Negligible.
- Boost can fire on non-doctor queries that mention "Dr. <Name>". Mitigation: the boost only matters if a doc with that title exists in the corpus; otherwise it's a no-op.
Rejected alternatives
- Modify the shared system-prompt template to include the schedule rule. Rejected — exactly the pollution we're avoiding. The shared template must stay hospital-agnostic.
- Add the doctor boost as a YAML rule per tenant. Rejected — the title convention is shared across hospitals; coding it once avoids 10 copies of the same pattern in 10 configuration files.
- Re-rank in a post-retrieval LLM step instead of a boost. Rejected — adds latency for what is essentially a deterministic title-match.
- Re-chunk the corpus to extract doctor schedules as structured data. Deferred to a future iteration. Layer 2 is needed regardless; the prompt rule provides immediate value while the schema work matures.
Follow-ups
- Companion change: a data-quality step extracts the consultation schedule into structured data stored with the document metadata. The prompt rule remains as defense-in-depth — it teaches the LLM to parse markdown when consumers have not yet been upgraded to use the structured field.
- Re-evaluate the 1.50 boost factor after a week of pilot data.