Building Agents with Closed-Source LLMs: Architecture, Workflows, and Governance

    This article explains how enterprises can build agent systems on closed-source large language models. It covers model alignment and content safety, single-agent versus multi-agent collaboration, dynamic workflows, a five-layer reference architecture, implementation logic for workflow scheduling, enterprise integration and operations, a security and compliance checklist, and a framework for evaluating model selection.

    1. Why Closed-Source LLMs Plus Agents Are Drawing Enterprise Attention

    The capability boundary of large language models has expanded rapidly from single-turn question answering to multi-step task execution. What enterprises actually need is not a longer piece of text, but a software entity that can read context, call tools, break down goals, validate results, and keep running. This is what is commonly referred to as an agent.

    Closed-source LLMs offer several practical advantages in this trend. Capability iteration is maintained by the vendor, so enterprises do not bear the cost of low-level training and tuning. The interface form is relatively stable, which makes engineering-side encapsulation easier. Safety alignment and content governance are usually built in by the vendor, reducing the pressure on enterprises to build their own compliance pipeline. At the same time, the closed-source route brings constraints: the model internals are invisible, the pace of version evolution is decided externally, and costs grow linearly with call volume. The engineering focus should therefore shift from “pursuing a stronger model” to “trading architecture for controllability.”

    2. Technical Characteristics: From Alignment Methods to Task Execution

    The technical features mentioned in the original material can be abstracted into three general engineering threads.

    2.1 Model Alignment and Content Safety

    Alignment usually refers to making model output better match human intent and established norms. Common industry practices include supervised fine-tuning, preference optimization based on human feedback, and “rule-driven” approaches that constrain model behavior with explicit principles. In engineering terms, this can be understood as three layers of defense:

    • Input layer: masking sensitive information, intent recognition, and blocking unauthorized requests;
    • Generation layer: behavioral guidelines in the system prompt, output format constraints, and refusal strategies;
    • Output layer: content moderation, factual validation, and citation tracing.

    It is important to emphasize that alignment is not a one-time configuration, but a governance process that requires continuous evaluation.

    2.2 Agents and Multi-Agent Collaboration

    A single agent is suitable for linear tasks. When a task involves parallel branches, specialized division of labor, or long-chain dependencies, multi-agent collaboration is more efficient. A typical role division is as follows:

    Role Responsibility Key Constraint
    Planner Goal decomposition, task graph generation Output a structured plan
    Executor Call tools to complete subtasks Idempotent, retryable
    Verifier Result comparison and quality scoring Independent context
    Aggregator Merge conclusions, produce deliverables Conflict resolution strategy

    The core risks of a multi-agent system are “error accumulation” and “context contamination,” so an explicit task graph, state storage, and termination conditions are required.

    2.3 Dynamic Workflows and Efficiency Optimization

    A dynamic workflow adjusts subsequent steps at runtime based on intermediate results, rather than following a fixed pipeline. Its engineering elements include task node abstraction, dependency description, concurrency control, failure rollback, and resume from breakpoints. Efficiency optimization covers general techniques such as prompt compression, cache reuse, batching, and model-tier routing (simple tasks go to small models, complex tasks go to large models).

    3. Reference Architecture: A Five-Layer Design

    1. Access layer: Web / mobile / internal systems / messaging and collaboration tools
    2. Orchestration layer: task graph engine, state machine, concurrency and retry policies
    3. Capability layer: model invocation, toolset (retrieval, database, computation, files)
    4. Data layer: vector index, relational storage, object storage, logging service
    5. Governance layer: permissions, audit, quotas, monitoring and alerting, evaluation regression

    The key value of layering is “replaceability”: the model can be swapped, tools can be swapped, and storage can be swapped, while business orchestration and governance policies remain stable.

    4. Implementing Dynamic Workflows

    The following code is a general pseudo-implementation used to illustrate the scheduling logic. It does not point to any specific product interface:

    1. class Node:
    2. def __init__(self, name, handler, depends_on=None):
    3. self.name = name
    4. self.handler = handler
    5. self.depends_on = depends_on or []
    6. def run_workflow(nodes, context, max_parallel=8):
    7. done, running, results = set(), {}, {}
    8. while len(done) < len(nodes):
    9. for n in nodes:
    10. if n.name in done or n.name in running:
    11. continue
    12. if all(d in done for d in n.depends_on):
    13. running[n.name] = n
    14. for name, node in list(running.items())[:max_parallel]:
    15. results[name] = node.handler(context)
    16. done.add(name)
    17. running.pop(name)
    18. if not running and len(done) < len(nodes):
    19. raise RuntimeError("The workflow has circular dependencies or unreachable nodes")
    20. return results

    In engineering practice, you also need to add node timeouts, result schema validation, human approval nodes, and a “maximum steps” circuit breaker to prevent the agent from falling into an infinite loop.

    5. Enterprise Integration and Operations

    Enterprise adoption is usually based on two delivery forms: interface calls for developers, and subscription-based services for organizations. The integration path generally follows “side path first, main path later”:

    1. Side-path pilot: validate benefits in low-risk scenarios such as customer service, document summarization, and code assistance;
    2. Process embedding: connect agents to existing processes such as ticketing, approvals, and reporting;
    3. Main-path carriage: take on critical chains only after a complete fallback plan is in place.

    Related business and operational points include billing by call volume or seats, quotas and rate limiting, tenant isolation, data retention policies, and clear cost accounting standards. A common industry practice is to introduce message queues for peak shaving, use object storage to archive long text, use container platforms to host tool sandboxes, and rely on logging, monitoring, and alerting systems to ensure observability.

    6. Security, Compliance, and Risk Control Checklist

    • Data classification: define which data can leave the domain and which must be processed locally;
    • Least privilege: authorize tool calls on demand, and prohibit default full read/write access;
    • Full-chain audit: record prompts, tool parameters, returned results, and the operator;
    • Prompt injection protection: isolate and label external content to prevent it from being executed as instructions;
    • Evaluation regression: build a fixed test set and automatically run regression after model or prompt changes;
    • Human fallback: require manual confirmation for high-risk actions.

    7. A Framework for Model Selection

    When evaluating closed-source models, it is recommended to score across six dimensions: task success rate, long-context stability, structured output compliance rate, tool-calling reliability, cost per task, and predictability of version changes. Be sure to build an evaluation set from your own business data rather than relying on public leaderboards.

    8. Conclusion

    The value of closed-source LLMs lies not in “replacing engineers,” but in encapsulating repetitive cognitive labor into schedulable software capabilities. If enterprises invest enough design effort in the orchestration and governance layers, they can keep the system stable, auditable, and extensible while models evolve rapidly. If managed infrastructure support is needed, you can combine general capabilities such as the container platform, object storage, logging service, and monitoring and alerting offered by Baidu AI Cloud to complete the implementation.