Designing Domain-Specific Consultation Workflows in a Plugin-Based Architecture

    As AI agents transition from single-turn Q&A to executing domain-specific workflows, ensuring process compliance and traceable decision-making becomes critical, especially in high-risk fields. This article explores a plugin-based architecture that decouples a minimal core runtime from domain capabilities. It details the six-stage consultation workflow, interaction design, confidence control gates, evidence chain management, and the engineering and security boundaries required to build responsible, auditable domain AI applications.

    Designing Domain-Specific Consultation Workflows in a Plugin-Based Architecture

    1. Background: From Prompt-Based Apps to Executable Workflows

    As agent applications evolve from single-turn Q&A to domain-specific workflow execution, developers face common challenges. Prompts can describe a workflow but cannot guarantee its execution; models can generate answers but struggle to prove their basis; interactions can be natural but often fail to reliably capture critical information. In high-risk domains such as healthcare, law, and finance, systems must not only “know how to answer” but also “know when not to answer,” while leaving a traceable decision chain.

    The architectural value of “everything is a plugin” lies here. It decouples the minimal core from domain capabilities: the core handles lifecycle, registration and discovery, workflow orchestration, state management, permission auditing, and observability. Domain capabilities are integrated as plugins, including information intake, symptom selection, differential matching, evidence verification, plan generation, and review defense. The direct benefits are: composable workflows, replaceable capabilities, versioned gray releases, auditable behaviors, and the ability to reject failures. For consultation scenarios, a plugin-based architecture can embed the design principle of “rather ask more than conclude early” directly into the engine, rather than just in the prompt.

    2. Architecture Overview: Minimal Core and Plugin Contracts

    The first principle of a plugin-based system is keeping the core as small as possible. The core does not carry specific domain knowledge or directly assemble prompts; instead, it provides stable plugin contracts and a workflow runtime. A viable plugin contract typically includes: plugin metadata, input/output structures, capability declarations, permission declarations, evidence source declarations, version numbers, dependency relationships, and failure semantics. Plugins must declare what they can and cannot do, what data they require, and what status they return upon failure.

    Schematic pseudocode:

    1. register_plugin({
    2. name: "intake",
    3. version: "1.2.0",
    4. input_schema: { session_id, user_profile },
    5. output_schema: { chief_complaint, duration, special_state },
    6. permissions: ["session:read", "session:write"],
    7. evidence_required: false,
    8. failure_semantics: "ask_more"
    9. })

    The orchestration layer can use a state machine or a lightweight DAG to link “Intake – Differentiation – Evidence – Generation – Review” into a rollback-capable chain. Each stage must have clear pre-conditions and exit conditions: no differentiation if information is incomplete, no generation if evidence is insufficient, and no final recommendation output if the review fails. Plugins pass structured states to each other rather than guessing via natural language context. This allows the system to unit-test each plugin and perform regression evaluation on the overall workflow.

    3. Domain Workflow Plugins: A Six-Stage State Machine

    Taking a Traditional Chinese Medicine (TCM) classic prescription learning assistant as an example, the domain workflow can be divided into six stages. The first stage is basic information intake: name, age, gender, chief complaint, duration, and special conditions (e.g., pregnancy, postpartum, lactation). The second stage is symptoms and signs collection: using multi-select cards to cover common discomforts, tongue and pulse conditions, and capturing ranges and values for temperature, blood pressure, and pulse. The third stage is differential matching: first presenting multi-select differentiation points, then offering single-select candidate prescriptions, displaying match scores and syndrome summaries. The fourth stage is evidence verification: retrieving internal classic literature databases and public medical literature databases to return evidence snippets, unique literature identifiers, evidence levels, and update times. The fifth stage is plan generation: it must re-verify the evidence and confidence level, rejecting generation if any gate fails. The sixth stage is review defense: displaying original text and literature numbers when challenged, providing evidence when maintaining the position, or rolling back to change the prescription when corrections are needed.

    Schematic workflow:

    1. state = consult_intake(session)
    2. state = collect_symptoms(state, stage="symptoms")
    3. state = collect_signs(state, stage="signs")
    4. diff = differentiate(state)
    5. if diff.confidence < THRESHOLD:
    6. state = ask_more(state, diff.missing_points)
    7. else:
    8. evidence = check_evidence(diff.candidates)
    9. if evidence.verdict != "supported":
    10. state = switch_alternative(state, evidence.alternatives)
    11. else:
    12. output = prescribe(state, diff, evidence)

    4. Interaction Design: Option Cards First

    The biggest risk in domain consultations is not that “the model cannot speak,” but that “the user cannot explain clearly.” Free-text questionnaires easily miss critical information and create ambiguity. The value of option cards lies in front-loading domain knowledge into a structured form: symptoms are grouped by system for multi-select; tongue, pulse, and differentiation points use single or multi-select; temperature, blood pressure, and pulse use ranges plus values. Users see clickable cards rather than a large paragraph requiring typing; the backend receives structured fields for easy validation, statistics, and review.

    The interaction layer should also support “multi-select with free-text supplement,” draft saving, rollback modifications, anomaly alerts, and accessibility design. More options are not always better; they must align with subsequent differentiation logic. Each option should map to a differentiation point or evidence retrieval keyword. Otherwise, collecting large amounts of information that cannot be used for decision-making only increases the burden.

    5. Three Gates and Confidence Control

    Workflow plugins should set three hard gates. The first is the information completeness gate: when required fields are missing, chief symptoms are insufficiently matched, or key differentiation points are uncollected, it only returns the next round of differentiation questions. The second is the pattern-syndrome matching gate: if the highest match score is below a threshold, the score difference between the first and second choices is too small, or the score difference is insufficient in high-match scenarios, it refuses to provide a candidate plan and continues asking. The third is the evidence support gate: if there is no literature support, insufficient evidence level, or evidence conflict, it refuses generation and returns alternative directions. Thresholds should be configurable, calibratable by scenario, and validated against rejection rates and follow-up rounds using offline evaluation sets and online gray releases.

    Schematic gate logic:

    1. def gate(diff, evidence):
    2. if diff.top_score < 0.60:
    3. return "ask_more"
    4. if diff.top_score - diff.second_score < margin(diff.top_score):
    5. return "ask_more"
    6. if evidence.verdict != "supported":
    7. return "switch_alternative"
    8. return "prescribe"

    Being “rejectable” is not a capability flaw, but a safety feature. The system automatically follows up for a limited number of rounds; if information remains insufficient, it clearly states that information is inadequate rather than forcefully providing a seemingly complete answer.

    6. Evidence Chain and Traceable Review

    Evidence verification must be a hard gate in the workflow, not a decoration after output. Plugins should maintain an evidence chain: literature sources, original text snippets, unique identifiers, evidence levels, update times, conflict flags, and retrieval times. Before plan generation, re-verify the evidence to avoid situations where “it was supported during differentiation but fails during generation.” When users challenge the result, review tools should display the basis and allow corrections; all review trails are written to audit logs, supporting manual review interfaces. This ensures technical traceability and meets compliance requirements for high-risk scenarios.

    7. Engineering Implementation and Security Boundaries

    In terms of engineering, plugins require registration and discovery, semantic versioning, dependency resolution, compatibility matrices, canary releases, and rollback mechanisms. The runtime should have sandbox isolation, least privilege, sensitive field masking, and audit logs. Evaluation metrics include follow-up rounds, information completeness rate, evidence coverage rate, rejection rate, false generation rate, manual review rate, and latency. Testing should cover contract testing, regression testing, adversarial testing, and red team evaluations.

    Regarding security and compliance, domain consultation plugins should explicitly be designated as learning and assistance tools, whose outputs cannot replace in-person consultations and licensed physician prescriptions. For toxic drugs, special populations, and high-risk scenarios, forced manual review is mandatory; dosage conversions use conservative strategies with warnings. Privacy data should be minimally collected, stored with masking, and accessed based on permissions. Only by achieving “extensible, auditable, and rejectable” simultaneously can a plugin-based architecture truly support responsible domain AI applications.