Domain Plugin Architecture: Staged Gates and a Closed Evidence Loop

    How to design domain-specific AI plugins that enforce staged workflows, hard gates, and evidence-backed decisions instead of relying on prompts alone. Covers structured intake, confidence and evidence thresholds, challenge handling, and a pre-launch checklist.

    When a domain system treats “conversation” as its only interface, models tend to produce confident-looking conclusions even when information is insufficient. A more robust approach is to distill a category of professional work into a plugin: the plugin doesn’t handle casual chat, but owns an interruptible, reversible, and auditable workflow. “Everything is a plugin” means capabilities exist not as verbal agreements written into prompts, but as callable stages with explicit inputs, outputs, and hard gates. Prompts can explain principles, but they cannot replace rejection conditions in the engine.

    Plugins Own the Workflow, Not the Writing Style

    A usable domain plugin needs at least four things. First, stage state: whether the process is in intake, differentiation, verification, or output—the caller cannot skip steps. Second, structured interaction: each step returns option cards, ranges, or limited free-text supplements, not a long questionnaire users must organize themselves. Third, independent gates: matching, evidence, and output are three separate gates; if any fails, the process stops there. Fourth, traceable records: every question, every rejection, and every revised conclusion must map back to inputs and rationale—not just a block of natural language.

    Take clinical learning and assisted consultation as an example. The plugin’s goal is not to replace in-person care or licensed physicians, but to encode “ask thoroughly first, then assess, and only form a plan when evidence is retrievable” as machine-executable sequencing. When individual users feel the questioning is thorough and the interaction smooth, that should come from stage design—not from the model being coincidentally diligent.

    Staged Intake: Ask More Rather Than Conclude Early

    The intake stage collects only identity and context, not professional judgment. Typical fields include name, age, sex, chief complaint, and duration, plus special conditions like pregnancy, postpartum status, and breastfeeding that must be flagged separately. These fields determine which follow-up questions apply and whether certain plans should be excluded outright. The chief complaint works best as a limited multiple choice with free-text supplement, covering common symptom categories—avoiding an open-ended long-form response that misses items and is hard to compare.

    Symptoms and signs are then split across multiple rounds. Each round adds one category of information: symptom groups, vital sign ranges such as temperature, blood pressure, and pulse (with values when necessary), and observation items like tongue and pulse findings. Options should be enumerable and countable; free text is supplemental only. This lets the engine compute whether key symptoms actually match, instead of relying on the model’s post-hoc claim that it understood the case.

    This design principle belongs in the scheduler: when information is insufficient, the tool’s only legal outputs are “keep asking” and the next differentiation question—it cannot output a plan. Automated follow-ups should have an upper bound, say a few rounds. If the threshold still isn’t met past that limit, the process explicitly ends with “insufficient information, recommend in-person consultation,” rather than lowering the bar to force an answer.

    Three Gates: Matching, Evidence, and Output Are Not Interchangeable

    The first gate is pattern or plan matching. Based on collected symptoms, the system presents differentiation points, lets users confirm key branches via multiple choice, then offers a small set of candidates with match scores and pattern summaries for single selection. The “match score” should come from explainable rules or reproducible scoring—weighting key symptoms, weighting secondary symptoms, deducting points for exclusion criteria—not from a paragraph of unverifiable adjectives.

    Confidence thresholds should be built in, not communicated as prompt instructions. For example: if key symptoms are insufficiently matched, the highest match falls below an agreed ratio, or the gap between first and second choice is too small, the plugin refuses to enter the candidate list and returns only the next differentiation questions. The gap threshold can vary slightly with the highest score: high matches allow a smaller gap, low matches require a clearer lead—preventing two weak candidates from being treated as “differentiated.” Thresholds themselves are policy configuration. Before launch, replay historical or teaching cases to observe false rejections and false passes; don’t pick a number by feel and declare it the one correct value.

    The second gate is evidence verification. Once candidates are fixed, the plugin should retrieve built-in classics or standardized texts, and where necessary query publicly traceable literature, returning passage locations, citation identifiers, supporting conclusions, and points of non-support. If retrieval returns nothing, results clearly contradict the candidate, or evidence quality falls below policy requirements, the verdict is “not supported.”

    Only the third gate produces the plan. Before output, evidence verification must run again—the system cannot rely on conversational memory of “we found evidence earlier.” If the verdict is not “supported,” the output interface rejects directly and returns alternatives, sending the flow back to differentiation. Rejection is part of the success path, not an exception.

    Handling Challenges: Both Persistence and Reversal Require Evidence

    In professional settings, users will challenge the selected plan, dosage policy, or differentiation. The plugin should offer a dedicated defend action: if the original judgment still holds, show passage locations and citation identifiers, and explain which key symptoms support the current choice; if the challenge reveals a missed exclusion criterion or stronger evidence, withdraw the plan on the spot, record the reason for the change, and return to differentiation or evidence. The defense must not become another unconstrained generation: the only condition for holding firm is that evidence still covers the current plan; the only condition for revising is that new information changed the score or the evidence verdict.

    Dosage, contraindications, and toxic ingredients must be policy-driven. Conversion ratios, prohibited populations, and drug categories requiring physician supervision should come from explicit configuration and a knowledge base—not from the model estimating on the fly. Entries involving toxicity or incompatibility should, by default, only display “must be used under the guidance of a licensed physician,” and an assistive tool should never provide directly executable dosages. Plugin output should always carry a fixed boundary statement: for learning and assistance only, not a substitute for in-person care or a legal prescription.

    Interaction Design and Engine Boundaries

    Patients and learners should see short cards: symptoms, tongue and pulse findings, differentiation points, candidate summaries. Long explanations live in an expandable layer. This lowers input cost and makes every step loggable. Free-text supplements must go through structured extraction; if extraction fails, treat it as unconfirmed—never let it directly raise the match score.

    A schematic stage contract can stay neutral and runtime-agnostic:

    1. consult(stage):
    2. intake -> symptoms -> signs -> differentiate -> evidence -> prescribe
    3. prescribe:
    4. if evidence.verdict != supported: return reject + alternatives
    5. else: return plan + citations + safety_notice
    6. differentiate:
    7. if confidence.below_threshold: return next_questions only

    The division of labor between engine and model must be clear. The model can organize language, explain differentiation points, and map free text onto options; whether a plan may be output is decided by the state machine and evidence verdict. Write “must check literature” only in a prompt, and the model may still skip it. Write the same condition as a precondition assertion on the output function, and skipping it fails.

    Plugins should follow the same contract with each other: register stages, declare which context fields they read, declare which verdicts they write. One plugin must not implicitly invoke another to “help produce a conclusion.” Composite flows should be described through orchestration, making it easy to swap evidence sources or scorers in isolation during testing.

    Testing, Observability, and a Launch Checklist

    Replay tests should cover at least three cases: sufficient information with supporting evidence, sufficient information without supporting evidence, and insufficient information. Assertions include: no plan text may appear in responses when the threshold isn’t met; evidence failures must include alternatives; output must be blocked when special-population fields are missing. For toxicity and contraindications, use rule-based tests rather than spot-checking a few conversations.

    Useful runtime metrics include: average number of follow-up rounds, rejection rate due to confidence, rejection rate due to evidence, rate of plan changes after challenges, and the stage where users abandon the flow. These metrics exist to surface “asking too much” or “letting too much through”—not to prove the model has reached some clinical credential. No claim of “approaching the level of a licensed physician” can be proven by individual usage experience, and should not appear in product promises.

    Pre-launch checklist: stages cannot be skipped; the three gates are independent; thresholds live in configuration; evidence is traceable; rejections are reversible; dosage and contraindications are never invented by the generative model; disclaimers are always visible; logs contain no unnecessary identity data in plain text. If the system is deployed in the cloud, intake records, literature caches, and audit logs should be stored separately, with access governed by least privilege and retention periods compliant with personal information and medical data regulations. Object storage suits audit packages, message queues decouple retrieval, and monitoring alerts watch for sudden changes in rejection rates. These are all generic capabilities, independent of any proprietary interface.

    Turning professional judgment into a plugin means writing caution into code paths: ask fully before judging, output only with evidence, stop when evidence is absent, and revise when wrong. The model handles expression and assisted classification; the workflow engine decides when speaking is not allowed. That is what “everything is a plugin” must mean to be maintainable long-term in serious domains.