Agent Workflow Orchestration with an Everything-as-a-Plugin Architecture

    This article explains how an "everything as a plugin" architecture turns unreliable LLM chat behavior into a controllable agent workflow. It covers splitting business processes into a staged state machine, replacing free-text input with option cards, enforcing confidence thresholds so the system keeps asking instead of concluding early, unifying evidence verification and fallback, and turning safety boundaries into hard rules. Readers will find interface sketches, decision logic, and practical implementation recommendations.

    1. The Starting Problem: Why “Being Able to Chat” Is Not “Being Able to Get Things Done”

    Agent practice over the past two years has exposed a shared contradiction: language models keep getting better at language, yet using that language ability directly as business capability produces uncontrollable output. A user raises a professional request; the system may skip the required information-gathering steps and jump straight to a conclusion. It may also fail to provide a basis when challenged, or conversely cling stubbornly to a wrong judgment.

    The “everything as a plugin” architecture is the engineering answer to this contradiction. Its core claim: the model is responsible only for understanding intent and organizing language, while the actual business rules, data validation, and threshold checks are all pushed down into plugins that can be developed, tested, and replaced independently. What a plugin exposes to the outside is a structured interface, not a prompt.

    The direct benefits span three levels:

    • Rules become verifiable. Business constraints live in code and can be covered by unit tests, instead of relying on the model to “remember” them.
    • Capabilities become replaceable. When one step performs poorly, only that plugin is swapped out; the overall flow is unaffected.
    • Flows become auditable. The inputs and return values of every tool call are recorded, so problems can be traced precisely to a specific step.

    2. Breaking a Business Process into an Executable State Machine

    Take a typical professional assistance scenario: a domain flow that must “ask first, then judge, then conclude.” Written as one long prompt, the model’s behavioral boundary is blurry. Split into plugins and stages, the flow becomes an explicit state machine.

    The stages can be abstracted into four layers:

    1. Intake: confirm basic information and the chief complaint, and output a structured profile.
    2. Symptoms / signs: expand the chief complaint into options, and confirm objective indicators and physical signs item by item.
    3. Differentiate: produce candidate options with match scores, and require the user to confirm the differentiating points.
    4. Evidence / prescribe: verify the basis, and allow a final conclusion only after it passes.

    A sketch of the interface shapes (structural only, not any specific product API):

    1. consult({ stage: "intake" }) -> { profile, missing[] }
    2. consult({ stage: "symptoms" }) -> { answers{}, confidence }
    3. differentiate({ answers }) -> { candidates[], followup? }
    4. evidence({ candidate }) -> { verdict, citations[] }
    5. prescribe({ candidate, verdict }) -> { result } | { reject, alternatives[] }

    The key design point: every stage returns structured data, and the next stage accepts only artifacts that passed the previous stage’s validation. The relationship between stages is not “suggestion” but “admission.”

    3. Interaction Design: Replacing Free Text with Option Cards

    In professional scenarios, free-text input is an amplifier of error rates. The user’s description is vague, the model’s understanding is skewed, and once the two stack up they produce a conclusion that looks reasonable but cannot be traced.

    The safer approach is to converge all questions into option lists:

    • The chief complaint uses multiple choice plus supplementary notes, covering common categories so users do not have to compose language from scratch.
    • Objective indicators (such as temperature, blood pressure, and pulse) offer range options while still allowing numeric entry, balancing efficiency and precision.
    • Physical-sign information (such as tongue appearance and pulse quality) enumerates common types, reducing ambiguity from synonymous descriptions.
    • Differentiating points are pushed up by the system proactively; the user only confirms rather than recalls.

    This interaction carries a hidden benefit: the options themselves are data. They are naturally structured, countable, and regression-testable, providing a clean data source for later quality evaluation.

    4. Confidence Thresholds: Teaching the System to “Keep Asking”

    “Better to ask more than to conclude early” should be written into the engine, not into a prompt. The deployable decision logic involves three types of conditions; if any one is unmet, outputting candidates is refused:

    • Insufficient hits on key chief symptoms;
    • The highest match score falls below a configured threshold (for example, 60%);
    • The gap between the top choice and the second choice is too small (for example, below 8%, tightened to 4% in high-match scenarios).
    1. if missing_key_symptoms or top_score < 0.60 or (top1 - top2) < margin:
    2. return { action: "ask_more", questions: next_questions(), round: r + 1 }

    An automatic follow-up limit is also needed (for example, 3 rounds). Once exceeded, the flow switches to “insufficient information; recommend additional objective examination or an in-person visit” instead of looping endlessly or letting the request through. This mechanism translates the vague state of “the model is uncertain” into control flow the system can execute.

    5. Evidence Verification and Rejection Fallback: Conclusions Must Be Traceable

    The last gate before output is basis verification. A plugin should carry searchable knowledge entries and retain the ability to extend to external literature retrieval; verification yields only two results, “supported” and “not supported.” When not supported, the output stage must refuse outright and return alternative directions, sending the flow back to the differentiation stage to run again.

    When challenged, the system needs two opposite but equally necessary capabilities:

    • When it should hold its ground, provide the original source text and a verifiable literature identifier;
    • When it should admit error, retract the conclusion immediately and recompute the candidates.

    Both capabilities share the same evidence interface; the only difference is whether the evidence holds. In engineering terms, this means a defense is not a piece of rhetoric but a re-executed verification call.

    6. Safety and Boundaries: Turning Disclaimers and Dosage Constraints into Hard Rules

    Any assistance system aimed at a professional domain must make boundaries a mechanism rather than a statement:

    • Output is limited to learning and assistance, and does not replace in-person diagnosis or prescriptions from licensed practitioners;
    • Dosage conversion uses conservative折算 with the conversion ratio explicitly labeled;
    • Entries involving toxic medicinal materials are forced to carry usage conditions and risk warnings;
    • Call logs are retained across the entire chain, making review and responsibility attribution easier.

    If the system is deployed in the cloud, general-purpose object storage can hold audit logs, a message queue can decouple long-running flows, a container platform can host the plugin runtime, and logging services plus monitoring and alerting can track failure rates and the distribution of follow-up rounds. These are all industry-standard capability categories; specific choices should be evaluated against compliance and cost requirements.

    7. Implementation Recommendations

    1. Define the state machine first, then write plugins. Stages and admission relationships are the foundation of the architecture.
    2. Put thresholds in code with unit tests, covering the three boundaries of “insufficient information,” “insufficient evidence,” and “close scores.”
    3. Make interaction option-first, turning user input into verifiable data.
    4. Unify the evidence interface so prescribing and defending reuse the same path.
    5. Build an offline evaluation set and use historical sessions to regression-test whether follow-up rounds and rejection rates converge.

    The value of “everything as a plugin” lies not in the number of plugins but in locking uncertainty inside a testable cage: the model handles expression, plugins handle adjudication, and the flow provides the safety net.