Designing an Intelligent Consultation Workflow with an All-Plugins Architecture
This article presents a technical design for an intelligent consultation workflow built on an all-plugins architecture, where the model handles intent understanding while business capabilities are split into independently replaceable plugins. It explains the four-layer structure, staged questioning, confidence gates that force the system to keep asking instead of concluding early, separate evidence verification and prescription review gates, and a defense plugin for handling challenges. It also covers safety and compliance boundaries, plus engineering recommendations for implementation. The content is a general technical design and does not constitute medical advice.
Designing an Intelligent Consultation Workflow with an All-Plugins Architecture
1. Background: Why “Being Able to Chat” Is Not the Same as “Getting Things Done”
Over the past two years, intelligent coding tools and agent frameworks have largely converged on an “all plugins” model: the model itself only understands intent and generates content, while real business capabilities are pushed down into a set of plugins that can be registered, replaced, and tested independently. The value of this architecture is that it separates the highest-uncertainty reasoning from the most deterministic process constraints and governs them differently.
This matters especially in consultation-style scenarios. A model that only asks follow-up questions tends to jump to conclusions when information is insufficient, while a system that only outputs long questionnaires shifts the interaction cost onto the user. The practical approach is to model the consultation as a state-machine-driven flow, where each stage is a plugin and each threshold is a verifiable decision.
Note that this article discusses a general technical design and does not constitute medical advice. Any output involving diagnosis or medication must be reviewed by qualified professionals.
2. Overall Architecture: Flows as Plugins, Thresholds as Contracts
In engineering terms, “all plugins” can be structured into four layers:
- Interaction layer plugins: render questions as option cards instead of making users type long text.
- Reasoning layer plugins: handle pattern matching, similarity scoring, and candidate ranking.
- Evidence layer plugins: retrieve built-in classical text and a live literature library, returning verifiable citation identifiers.
- Governance layer plugins: handle confidence thresholds, refusal strategies, audit trails, and safety notices.
The four layers communicate through explicit data contracts, and any plugin can be replaced without affecting the main flow. A schematic plugin registry looks like this:
PLUGINS = {"intake": IntakePlugin(), # Collect basic information"symptoms": SymptomPlugin(), # Multi-select symptoms"signs": SignPlugin(), # Tongue, pulse, and physical signs"differentiate": DifferentiatePlugin(), # Differentiation and candidates"evidence": EvidencePlugin(), # Text and literature verification"prescribe": PrescribePlugin(), # Output after review"defense": DefensePlugin(), # Evidence-based defense}
The main flow only handles state transitions and carries no business details:
def run(state):while not state.done:plugin = PLUGINS[state.stage]result = plugin.execute(state)state = result.next_state(state)return state.output
The direct benefit is that adding a new specialty flow only requires registering new plugins and new state transition rules, with no changes to the engine.
3. Staged Consultation: Building “Ask First” into the Engine
The core principle in the original practice is “better to ask more than to conclude early.” To make this a system property rather than a slogan in a prompt, the follow-up logic must be fixed inside the plugins.
The first stage collects basic information with a small set of structured questions at once: name, age, gender, chief complaint, duration, and special circumstances (such as pregnancy, postpartum, or breastfeeding). Keep the field count to around six to avoid overloading the first screen.
The second stage collects symptoms using a hybrid mode of multi-select plus free-form additions, covering common categories of discomfort. The third stage collects physical signs, including range options and numeric input for temperature, blood pressure, and pulse, plus structured entries for tongue and pulse. Discretizing continuous values into ranges reduces the user’s judgment burden while preserving the ability to compare across layers later.
A schematic stage definition:
STAGES = [("intake", ["Name", "Age", "Gender", "Chief complaint", "Duration", "Special circumstances"]),("symptoms", ["Primary symptoms (multi-select)", "Accompanying symptoms", "Additional notes"]),("signs", ["Temperature range", "Blood pressure range", "Pulse range", "Tongue", "Pulse"]),("differentiate", ["Differentiation points", "Candidate options"]),("evidence", ["Text verification", "Literature verification"]),("prescribe", ["Review", "Output"]),]
The key constraint at the interaction layer is that all questions are presented as option lists. Options not only improve input efficiency but, more importantly, give later scoring and statistics a comparable structured basis.
4. Confidence Thresholds: Teaching the System to Say “Keep Asking”
Concluding too early is the most common failure mode in consultation-style applications. Three gates can intercept it in engineering:
- Insufficient primary symptom hits: when the coverage ratio of core symptom entries is below a threshold, entry into the candidate stage is refused outright.
- Top match too low: when the highest score among candidates is below a set threshold, the evidence is insufficient to support differentiation.
- Candidate score gap too small: when the gap between the first and second choices is insufficient, differentiation is not yet complete.
The candidate list is shown only when all three gates pass; otherwise the plugin returns the next round of differentiation questions and caps the number of automatic follow-ups to avoid infinite loops.
def gate(scores, primary_hits):top, second = scores[0], scores[1]if primary_hits < 0.5:return "ask_more"if top.score < 0.60:return "ask_more"margin = 0.04 if top.score >= 0.85 else 0.08if top.score - second.score < margin:return "ask_more"return "show_candidates"
Tightening the score-gap requirement moderately in high-match scenarios is a reasonable engineering trade-off: the closer to certainty, the stronger the differentiation needed.
5. Evidence Verification and Prescription Review: Two Independent Gates
Determining candidates does not mean output is allowed. The evidence plugin handles two types of retrieval: structured matching against built-in classical text, and live retrieval from an external literature library, returning verifiable citation identifiers. Before output, the prescription plugin re-reviews the evidence conclusion once, forming a second independent gate.
The design point here is “separation of responsibilities”: the matching plugin does not verify, the verification plugin does not prescribe, and the prescription plugin does not score. A misjudgment by any single plugin is hard to pass straight through to the final output.
def prescribe(state):verdict = evidence(state.candidate)if verdict.status != "supported":return Result(blocked=True, alternatives=verdict.alternatives)return Result(output=format(state.candidate), audit=state.trace)
When the evidence conclusion is not “supported,” the flow refuses output directly and falls back to the differentiation stage, reconverging with alternative directions.
6. Evidence-Based Defense: Handling Challenges as a Tool
The ability to handle challenges should be an independent plugin rather than ad-hoc phrasing. Its logic has two branches: if the evidence is sufficient, it outputs the original basis and verifiable literature identifiers and holds the original judgment; if the evidence is insufficient, it revises the conclusion on the spot and explains the reason for the change.
def defense(state, challenge):ev = evidence(state.candidate)if ev.status == "supported":return {"stance": "hold", "citations": ev.citations}return {"stance": "revise", "reason": ev.gap, "next": differentiate(state)}
This structure of being able to both hold and admit error is more reliable than simply emphasizing confidence, because it binds conclusions to evidence rather than to tone.
7. Safety and Compliance Boundaries
Any health-related flow must have hard boundaries built in: clearly label it as a learning and assistance tool; state that output cannot replace in-person consultation or licensed prescriptions; require mandatory notices for entries involving special populations; require content with toxic components to be used under professional guidance; and use conservative conversion with explicit labeling for dosage calculations. For auditing, it is recommended to fully retain the state transition trace and evidence citations for later review.
8. Engineering Benefits and Implementation Recommendations
The benefits of all plugins are clear: replaceable capabilities, testable flows, configurable thresholds, and traceable audits. For implementation, start with three things: first define the stages and data contracts clearly, then make the threshold parameters configurable, and finally add independent test cases for each plugin. If retrieval and audit-trail capabilities need to be supported, you can use object storage for audit records, a message queue to decouple stage calls, a container platform to host the plugin runtime, and logging services with monitoring and alerting to cover exception paths, keeping the whole system operable without introducing tight coupling.
