AI Agent Workflow Orchestration with an Everything-as-a-Plugin Architecture
This article explains how an "Everything as Plugin" architecture solves the core gap between conversational AI and task completion, where strong language ability does not guarantee finished work. It covers the four-layer design of a dispatcher, plugin runtime, plugin layer, and capability layer; how to separate deterministic judgment from generation; explicit state machine orchestration with multiple gates and bounded follow-up loops; structured option-card interaction; evidence traceability and review; and security, compliance, and fallback practices. A final checklist helps teams build agent workflows that are deliverable, auditable, and maintainable.
AI Agent Workflow Orchestration with an Everything-as-a-Plugin Architecture
1. The Problem: Being Able to Chat Is Not the Same as Getting Work Done
Agent practice over the past two years keeps exposing the same contradiction: language models keep getting better, but the share of tasks actually completed has not improved at the same pace. The reason is not mysterious. Conversation is open-ended, while business processes are closed loops. Business requires complete inputs, checkable rules, traceable conclusions, and reversible exceptions, and pure prompt-driven dialogue lacks all four by nature.
“Everything as Plugin” is one architectural response to this contradiction: treat model capability as a dispatching hub and push all business capability down into independent plugins. The model only understands intent, selects tools, and organizes results, while concrete judgments are made by deterministic logic inside the plugins. The direct benefits are replaceable capabilities, auditable flows, localizable failures, and enforceable compliance.
It is worth stressing that pluginization is not exposing functions under new names. It is a redrawing of responsibilities: which judgments go to the model, which must go to code, and which conclusions must leave a trace. This article uses a multi-gate flow of “structured intake, differentiation, evidence check, output” as a sample to show how to design a rigorous plugin system.
2. Architecture Overview: Dispatcher, Plugin Runtime, and Capability Layer
A deployable plugin architecture usually has four layers.
- Dispatch layer: handles intent recognition, plugin selection, parameter assembly, and result aggregation. It should be “thin” and carry no business rules.
- Plugin runtime: handles plugin registration, version management, timeouts and retries, idempotency control, permission checks, and call chain logging.
- Plugin layer: each plugin does one thing, with inputs and outputs constrained by explicit schemas, and internally replaceable implementations.
- Capability layer: foundational capabilities such as data retrieval, rule computation, external queries, storage, and messaging, carried by general cloud product categories such as object storage, message queues, container platforms, logging services, and monitoring and alerting.
An illustrative plugin registration structure (pseudocode that expresses only the contract and points to no specific product):
{"name": "consult","version": "1.3.0","inputSchema": { "stage": "enum[intake,symptoms,signs]" },"outputSchema": { "questions": "array<Question>", "nextStage": "string" },"timeoutMs": 3000,"retryable": false,"audit": true}
Contract first is the first principle of pluginization. As long as the input and output schemas stay stable, swapping implementations, models, or data sources inside a plugin will not affect the upper-level flow.
3. Drawing Boundaries: Separating “Judgment” from “Generation”
The most common plugin design failure is writing judgments that should be deterministic into prompts. For structured intake, the right approach is to split the work into three independent plugins rather than one all-purpose intake plugin.
- Collection plugin: only asks, never judges. It outputs structured fields and keeps asking when fields are missing.
- Differentiation plugin: only returns candidates and confidence, and does not draw conclusions.
- Evidence plugin and output plugin: handle verification and production, and must stay independent of each other; if verification fails, output is rejected.
The essence of this split is separating generation from decision. Generation can be probabilistic; decisions must be rule-based. Three hard constraints belong in the runtime rather than in prompts:
- When information is insufficient, tools may only return “keep asking” and may not return a conclusion.
- If any gate is not passed, the flow must not skip stages.
- Every rejection must come with an executable next step (an alternative or the next round of questions).
4. State Machine Orchestration: Multiple Gates and Automatic Follow-Up
Multi-gate flows are best expressed with an explicit state machine, which avoids the model skipping steps at will.
intake → symptoms → signs → differentiate ⇄ (follow-up for at most 3 rounds)→ evidence → prescribeevidence=unsupported → differentiate (switch candidates)
There are three key design points.
First, front-load the gates. The collection stage should already cover demographic information, chief complaint, disease course, and special physiological states (such as pregnancy, postpartum, and lactation), because these fields directly determine whether the later candidate set is valid.
Second, a confidence gate. The differentiation plugin has a built-in threshold check: when the main symptom match is insufficient, when the highest match score is below the configured threshold, or when the gap between the top and second choice is too small (the gap requirement can be tightened for high matches), it refuses to output candidates and returns only the next round of differentiation questions, with a cap on automatic follow-up rounds to prevent infinite loops.
Third, reversibility. When the evidence check fails, the flow does not terminate but returns to the differentiation stage carrying alternative candidates. The fallback path must be declared explicitly in the state machine; otherwise the runtime ends up with “orphan states.”
5. Structured Interaction: Option Cards Instead of Long Questionnaires
Open-ended questions significantly increase input noise and make validation harder. A more engineering-friendly approach is to compile questions into option cards: multi-select symptoms, enumerated tongue and pulse observations, dual-channel ranges plus numeric values for temperature, blood pressure, and pulse, multi-select differentiation points, and a single-choice candidate list with match scores and summaries.
The benefits go both ways: input cost drops on the user side, and the service side receives enumerated values it can validate directly. A sample structure:
{"question": "Tongue appearance","type": "single","options": ["Light red", "Pale white", "Red", "Purple dark"],"allowFreeText": true,"required": true}
Three engineering points also matter: enumerated values must be versioned so historical data stays parseable; free text is only a supplementary channel and must be labeled with its source; and every card submission must pass schema validation, with invalid input rejected outright rather than “interpreted on a best-effort basis.”
6. Evidence and Traceability: Making Conclusions Verifiable
In high-rigor scenarios, the core is not “answering correctly” but “answering in a way that can be checked.” The evidence plugin should support both built-in knowledge base retrieval and real-time external queries, and return locatable citation identifiers. The output plugin re-checks the evidence status once before producing results, forming a double safeguard.
A “defense” mechanism must also be built in: when facing a challenge, the system either stands its ground with the original text and verifiable identifiers, or corrects itself on the spot and leaves a trace. Technically this is equivalent to a second review with auditing, and its value is bringing dispute handling into the flow instead of relying on improvisation.
7. Security, Compliance, and Fallback
Any assistive tool aimed at a professional domain must write its boundaries into the architecture rather than into a disclaimer. Practical measures include: attaching a fixed purpose statement to outputs; forcing human confirmation for high-risk items; centralizing and auditing dosage and conversion rules; and blocking by default any plan containing high-risk ingredients until a professional releases it.
At the runtime level, it is advisable to add full-chain call logging and metrics collection, plugin-level circuit breaking and timeout fallback, canary releases and version rollback, and masked storage of sensitive fields. Relying on general cloud capabilities (container platforms to host plugins, message queues to decouple asynchronous verification, logging services and monitoring and alerting for observability, object storage to keep audit material) makes this engineering work possible without binding to proprietary interfaces.
8. Deployment Checklist
- Contracts: does every plugin have explicit input and output schemas and a version number.
- Decisions: which conclusions are decided by code, and whether they have been stripped out of prompts.
- Gates: is stage skipping possible, and does the rejection path provide a next step.
- Loops: is there a cap on automatic follow-up, and is fallback explicitly declared.
- Interaction: are questions structured, and is invalid input rejected.
- Traceability: can conclusions point to locatable citations, and is there a second review.
- Compliance: are high-risk paths forced through human confirmation, and are fallback and auditing in place.
The real value of “Everything as Plugin” is not the number of plugins but confining uncertainty: the model handles understanding and expression, plugins handle rules and evidence, and the runtime handles constraints and traces. With clear division of labor among the three, complex business work becomes deliverable, auditable, and able to evolve sustainably.
