Everything-Is-a-Plugin Architecture for Complex Business Workflow Orchestration: A Practical Case

    This article explains how an "everything is a plugin" architecture keeps LLM-driven workflows rigorous and reliable in high-stakes fields. Using a traditional Chinese medicine (TCM) consultation assistant built on an open-source LLM plugin engine as an example, it covers state-machine orchestration of plugin nodes, confidence-gated progression, evidence verification, and the rollback logic the engine enforces.

    Large language models (LLMs) face a central challenge when applied to vertical domains: how to keep the advantages of natural language interaction while ensuring that business processes are rigorous and results are reliable. Traditional prompt engineering often fails to prevent hallucinations or stop models from skipping key steps. To address this, the “everything is a plugin” design philosophy has gradually become an industry consensus. This architecture breaks a complex business process into independently callable plugin nodes. A state-machine-driven orchestration approach then combines the generative capabilities of LLMs with the deterministic logic of conventional software engineering.

    This article uses a TCM intelligent consultation assistant, built on an open-source LLM plugin engine, as an example. It shows how the “everything is a plugin” architecture keeps complex workflows rigorous in real engineering practice.

    1. Business Pain Points and Architecture Choice

    In high-stakes fields such as medicine, letting an LLM generate prescriptions directly carries serious risk. The model may reach a hasty conclusion from a patient’s brief description, or recommend folk remedies without support from classical texts. To solve this, the development team did not rely only on a system prompt. Instead, they used the “everything is a plugin” architecture to turn classical formula-based consultation into an executable, verifiable workflow plugin.

    The core design principle is to split the business into several independent gates. If any check fails, the workflow does not advance to the next step. This replaces the black-box, free-form behavior of an LLM with a controlled execution engine.

    2. Workflow Decomposition and State-Machine Orchestration

    Under this architecture, the entire consultation is designed as a multi-stage state machine. Patients do not face a long questionnaire that requires extensive typing. Instead, they interact through structured option cards, such as multi-select symptoms, single-select tongue appearance, and pulse ranges.

    1. Basic Information Collection

    At the start of the workflow, the system calls the intake plugin. This stage displays standard option cards to collect the patient’s name, age, gender, chief complaint, duration of illness, and special conditions such as pregnancy or postpartum status.

    1. // Pseudocode: initial state invocation
    2. {
    3. "stage": "intake",
    4. "fields": ["name", "age", "gender", "chief_complaint", "duration", "special_condition"]
    5. }

    The chief complaint uses multiple-choice questions with an optional free-text field, covering nine common categories of discomfort. This lowers the barrier to expression while keeping the input structured.

    2. Symptom and Sign Entry

    After intake, the workflow triggers the symptom collection plugin and then the sign collection plugin. In total, this stage includes about 21 standardized questions. They cover 90 symptom options, 12 tongue features, and 13 pulse features, plus range selections for body temperature, blood pressure, pulse rate, and other physiological indicators. The card-based interface is smooth to use. More importantly, it produces standardized feature vectors for later algorithmic matching.

    3. Syndrome Differentiation and Formula Matching

    Once intake is complete, the workflow calls the syndrome differentiation plugin. The system first shows a multi-select “key differentiating points” card, asking the patient or operator to confirm the key diagnostic symptoms. It then runs formula-syndrome matching on the collected feature vector and displays a single-select “candidate formulas” card. Each candidate includes a match percentage and a summary of the formula-syndrome correspondence.

    4. Evidence Verification and Prescription Generation

    This is the most critical safety valve in the workflow. After a candidate formula is selected, the workflow enters evidence verification. The system searches its built-in database of classical TCM texts and open academic literature databases for support linking the formula to the current symptoms. Only after verification passes does the prescription generation plugin issue the final prescription. It then calculates dosages using conservative clinical conversion rules, such as 1 liang = 3 grams.

    3. Core Design Principles and Fault Tolerance

    The plugin engine enforces several design principles. These are not only suggestions in prompts. They are hard-coded as logic constraints at the engine level.

    1. Ask More Before Concluding

    The syndrome differentiation plugin sets strict confidence thresholds. In the following cases, the system refuses to offer formula options. It forces the workflow into another round of differentiating questions, up to three automatic follow-up rounds:

    • the number of matched primary symptoms is insufficient;
    • the highest match score is below 60%;
    • the score gap between the top two formulas is less than 8% (4% when match scores are high).

    This mechanism ensures that when information is insufficient, the model asks for more information. It does not force a plausible but unsupported conclusion.

    2. Closed-Loop Verification and Rollback

    When the evidence verification plugin finds that the candidate formula lacks sufficient academic support, meaning it returns an “unsupported” result, the prescription plugin refuses to execute. It returns a list of alternative formulas and rolls the workflow state back to syndrome differentiation to rerun formula-syndrome matching. This “no evidence, switch formula” loop prevents the output of prescriptions without a basis.

    3. Rebuttal Mechanism

    Questions from users are unavoidable in medical settings. The plugin includes a built-in rebuttal tool for defending correct conclusions. When a user questions a result, the system does not concede blindly. It checks its knowledge base. If the original judgment was correct, it presents the classical source text and literature identifiers such as PubMed IDs (PMIDs). If there was a real error, it corrects the prescription on the spot. This mechanism improves the system’s explainability and credibility.

    4. Architecture Reflections and Summary

    The “everything is a plugin” architecture reduces the LLM from an all-knowing generator to an intelligent dispatch hub. In this design, the LLM interprets user intent and extracts key information. Business rules, data validation, and external retrieval are handled by deterministic plugins.

    This pattern offers a strong reference for building AI applications with high reliability and fault tolerance. Scenarios that demand high accuracy, such as medical consultation support, legal document review, and financial risk assessment, can apply the same design. Split the process into independent gates, drive node transitions with a state machine, and control progression with confidence thresholds. Engineering measures that keep an LLM within firm limits are what allow AI to be deployed safely in specialized fields.