Everything Is a Plugin: Executable Workflow Architecture for AI Agents

    This article explains the "everything is a plugin" architecture for AI agents, which packages professional workflows as executable plugins instead of letting a large language model answer freely. It uses a structured consultation plugin from a traditional Chinese medicine (TCM) assistive tool as a case study. Topics include option-based intake, three independent decision gates, safety logic enforced in code rather than prompts, and conclusions linked to evidence. It also outlines how the pattern can map to cloud infrastructure in enterprise deployments.

    From Direct Model Answers to Workflows as Plugins

    When large language models are applied to professional domains, the most common failure is not a lack of intelligence. The model rushes to a conclusion. Given a vague description from a user, it produces a plan that looks complete. Missing information, unverified steps, and absent evidence are hidden by the fluency of the language.

    The “everything is a plugin” agent architecture addresses this by not letting the model improvise. Instead, the professional workflow itself is packaged as an executable plugin. The model handles understanding and generation. Plugins define which steps must be followed, what the pass condition for each step is, and what to do when a condition is not met. This architecture is usually hosted by a runtime framework, called a harness. The harness only provides scheduling. All business logic is mounted as plugins, which are decoupled and can be replaced independently.

    The following example uses a “structured professional consultation” plugin to show how this architecture works in practice. The example comes from an assistive tool for classical formula-based traditional Chinese medicine (TCM), but the design applies to any high-risk field that needs to collect information first, make a judgment next, and decide last.

    Note: Tools of this kind are for learning and assistance only. Any output related to health cannot replace an in-person diagnosis and prescription from a qualified professional. This article discusses engineering architecture, not medical advice.

    First Design Decision: Use Option Cards Instead of Free Text

    Traditional questionnaires ask users to type a long description of their situation. The result is information that is incomplete and hard to structure. The plugin takes the opposite approach. Each interaction returns a set of option cards, and the user selects from them.

    The consultation is split into stages. Each stage corresponds to one plugin call:

    1. consult(stage="intake") → Basic information: name, age, sex, chief complaint, disease duration, special circumstances
    2. consult(stage="symptoms") → Multiple-choice symptoms, grouped by common discomforts
    3. consult(stage="signs") → Clinical signs: range options for temperature, blood pressure, and pulse, plus numeric input

    This design has three engineering benefits:

    • Parsable output: Options are predefined enumerated values. Downstream logic can match them directly, without fragile secondary extraction from free text.
    • Controlled coverage: Symptoms, tongue appearance, and pulse qualities are split into dozens to hundreds of selectable items. This covers key dimensions without omissions and reduces the chance that users skip fields.
    • Low interaction burden: Users tap instead of typing, so the flow is smoother and more people complete it.

    One general principle applies: always ask questions with option lists. Having the system generate the questions and the user answer multiple choice is the most effective way to reduce comprehension costs for both sides.

    Second Design Decision: Split the Decision into Separate Gates

    Dangerous outputs often come from trying to reach a conclusion in one step. The plugin splits a single professional judgment into three independent gates. If any gate fails, no final conclusion is produced:

    1. Matching gate: Match candidate formulas against the collected information. If the match is not yet clear, the system first presents differentiating key points so the user can narrow the options, then returns a candidate list with match scores.
    2. Evidence gate: Check the literature for each candidate. This includes built-in classical texts and external literature retrieval services that return current evidence.
    3. Decision gate: Review the results of the first two steps again before any conclusion is issued. The output is released only if all checks pass.

    The serial logic can be expressed in pseudocode:

    1. def prescribe(case):
    2. match = differentiate(case) # Gate 1: formula-pattern matching
    3. if not match.confident:
    4. return ask_more(match.questions) # Not enough confidence: keep asking
    5. evidence = check_evidence(match) # Gate 2: literature verification
    6. if evidence.verdict != "supported":
    7. return alternatives(match) # No supporting evidence: fall back to other candidates
    8. return finalize(match, evidence) # Gate 3: final review before output

    The key point is that the three gates are independent. A high match score does not mean the literature supports it, and having literature support does not mean the final review can be skipped. Decoupling the gates means any failure can be traced to its exact location, instead of the whole system failing as a black box.

    Third Design Decision: Put Safety Logic in the Engine, Not the Prompt

    Many developers try to constrain a model with prompts such as “Be careful and do not conclude hastily.” This kind of constraint is soft, and the model can ignore it. A more reliable approach is to write the constraint as a hard decision in the engine.

    The core principle of this plugin is “better to ask more than to conclude too early.” It is implemented as a set of explicit confidence thresholds:

    • If the key symptom hits are insufficient, the system refuses to give a conclusion.
    • If the top match score is below the set threshold, the system refuses to give a conclusion.
    • If the gap between the top and second-ranked candidates is too small, making them hard to tell apart, the system refuses to give a conclusion.
    • When any of these conditions applies, the system returns only the next round of differentiating questions. It also caps the number of automatic follow-up rounds to prevent endless loops.
    1. def differentiate(case):
    2. ranked = rank_candidates(case)
    3. top, second = ranked[0], ranked[1]
    4. if case.key_symptoms_hit < MIN_HITS \
    5. or top.score < MIN_SCORE \
    6. or (top.score - second.score) < MIN_GAP:
    7. return need_more_questions(case) # Insufficient information: keep asking
    8. return ready(ranked) # Thresholds met: proceed to the next gate

    When information is insufficient, the tool’s only action is to keep asking, not to guess. This turns “caution” from a wish into an executable, testable, and auditable code path.

    Fourth Design Decision: Make Conclusions Defensible

    A professional tool must do more than produce conclusions. It must also respond to challenges. This plugin has a built-in defense capability. When a conclusion is questioned, the plugin keeps its position where it is justified by citing the original text and literature reference numbers. Where a correction is warranted, it acknowledges the error and adjusts the plan on the spot.

    This reflects a broader principle: every conclusion should be traceable to evidence. A conclusion is not wording the model generated out of nothing. It is a verifiable claim tied to a specific source. When evidence is sufficient, the system cites it. When evidence is insufficient, the system falls back and starts over. This makes every step of the system reviewable.

    General Value of Plugin-Based Architecture

    Abstracting this case, the “workflow as plugin” architecture has several properties worth applying in other settings:

    • Decoupling and replaceability: Each capability, such as intake, matching, verification, and decision, is an independent plugin. It can be upgraded or replaced without affecting the rest of the system.
    • Constraints pushed down into the engine: Key safety and quality logic lives in the engine and does not depend on the model’s self-discipline. Results are predictable and testable.
    • Evidence binding: Outputs are linked to their sources, so they can be traced and defended. This suits high-risk domains.
    • Structured interaction: Option cards drive the dialogue, which lowers costs for both sides and improves data quality.

    Teams that want to deploy agents in enterprise settings can implement this approach with mature cloud infrastructure. Object storage can hold structured case records and session logs. Message queues can chain asynchronous calls across multiple plugins. Log services and monitoring alerts can track whether each decision path hits the expected gates. Platforms such as Baidu AI Cloud, which provide general-purpose large model and infrastructure capabilities, can serve as a foundation for hosting plugin-based agents of this kind. Reliability still depends on breaking the professional workflow into clear steps and enforcing constraints in the engine.

    Summary

    A smarter model matters less than a more reliable process. The value of “everything is a plugin” does not depend on how strong the model is. It lies in using engineering to formalize a professional way of working: ask clear questions first, make a judgment next, and decide only with evidence. When safety logic moves from prompts into code, and conclusions move from wording into traceable evidence, an agent becomes fit for high-risk professional settings.