Multi-Agent System Engineering: A Practical Guide to LLM Application Deployment
As foundation models converge on core capabilities, the real bottleneck for LLM applications has shifted to engineering. This guide presents multi-agent collaboration as a general engineering pattern, covering capability abstraction, role design, context governance, evaluation, cost and stability control, and security boundaries. It is intended for developers and architects who need to turn probabilistic models into stable, observable, and operable business systems.
1. The Turning Point: From Model Capability Races to Engineering Capability Races
Over the past two years, the dominant narrative in the LLM space has been parameter scale, leaderboard rankings, and breakthroughs in individual capabilities. Recent technical progress, however, shows a new kind of equilibrium: mainstream foundation models are gradually converging on core abilities such as logical reasoning, multimodal understanding, long-context processing, and Function Calling. The gap between leading models now shows up mostly in scenario-specific tuning details rather than a generational capability divide.
This leads to a pragmatic conclusion: foundation-level capability is becoming “good enough.” For the vast majority of enterprise applications, waiting for the next generation of models to solve business problems is yielding rapidly diminishing returns. The real bottleneck has moved outside the model itself—how to package an uncertain, probabilistic model into an engineering system that is stable, observable, operable, and billable.
This article does not focus on any specific product. Instead, it abstracts “multi-agent collaboration” into a general engineering pattern and discusses how to put it into practice in real projects.
2. Capability Abstraction: Three Foundation Capabilities That Enable Applications
Before discussing engineering practice, it helps to define three capabilities that current foundation models generally possess. They are the prerequisites for all subsequent architecture design.
1. Structured reasoning
Models can maintain logical consistency across multi-step reasoning, express intermediate states in a chain-of-thought style, and map natural-language conclusions into data structures that programs can consume through structured output (for example, JSON Schema constraints). This is the first bridge for connecting a model to a business system.
2. Unified multimodal understanding
Text, images, audio, and video are mapped into a unified representation space, allowing the model to cross-reference information from different modalities within the same context. The engineering significance is clear: pipelines that previously required chaining multiple specialized models (OCR → classification → extraction) can now collapse into a single call, significantly reducing pipeline complexity and latency.
3. Tool calling and state retention
A model can emit a structured call intent, an external runtime executes the real action (querying a database, making a request, writing a file), and the result is fed back into the context to continue reasoning. This turns the model from “generating text” into “driving a workflow,” which is the technical foundation that makes an agent viable.
3. The Core Pattern: Multi-Agent Collaboration, Not a Single Monolithic Prompt
A single monolithic agent—one prompt designed to handle everything—performs well in demos but often loses control in production due to overloaded responsibilities. The essence of multi-agent collaboration is separation of concerns: split a complex task across multiple execution units with limited responsibilities, and have an orchestration layer schedule them centrally.
A practical role breakdown looks like this:
| Role | Responsibility | Input | Output |
|---|---|---|---|
| Planner | Task decomposition, dependency ordering | User goal | Task graph (DAG) |
| Worker | Implementation of a single node | Subtask description | Artifact + status |
| Critic | Validation, rework decision | Execution artifact | Pass/reject feedback |
| Memory | Cross-session fact retention | Structured events | Retrievable context |
The key design principle is least privilege: each worker receives only the subset of tools and the data scope required to complete its node. This is both a security requirement and an effective way to limit hallucination propagation—errors are contained within a single node and do not amplify along the chain.
A schematic task graph definition (pseudocode, structure only):
task_graph = {"nodes": [{"id": "n1", "role": "planner", "tools": []},{"id": "n2", "role": "worker", "tools": ["db_query"], "depends_on": ["n1"]},{"id": "n3", "role": "worker", "tools": ["http_get"], "depends_on": ["n1"]},{"id": "n4", "role": "critic", "tools": ["schema_validate"], "depends_on": ["n2", "n3"]},],"retry": {"max": 2, "on": ["schema_error", "critic_reject"]},"timeout_ms": 30000,}
4. Context Governance: The Real Difficulty in Multi-Agent Systems
In most multi-agent failure cases, the problem is not that the model is not smart enough; it is that context management has spiraled out of control. Three layers of mechanisms are needed:
- Short-term context: Keep only the current node’s inputs and outputs plus necessary reasoning summaries. Overly long history must be compressed into structured summaries rather than stacked as raw text.
- Long-term memory: Write events to external storage and recall them via vector retrieval plus metadata filtering, avoiding “stuffing everything in.”
- Shared blackboard: All agents read and write the same structured state, using version numbers or optimistic locking to guarantee consistency and prevent concurrent writes from overwriting each other.
A strong engineering recommendation: communication between agents should use structured contracts (explicit fields and types), not free text. Free text creates implicit coupling between upstream and downstream, where any prompt tweak can break the chain.
5. Evaluation: No Measurement, No Improvement
Traditional single-turn evaluation (leaderboard scores) cannot reflect system-level performance. Production requires three layers of evaluation:
- Component layer: Schema validity rate of single-node output, correctness rate of tool-call parameters.
- Pipeline layer: End-to-end task success rate, average rework count, average number of steps.
- Business layer: Human adoption rate, cost per task, P95 latency.
The recommendation is a dual-track mechanism: an offline regression set (covering typical and edge cases) plus online canary comparison. Every time you adjust a prompt or a model version, the regression set must pass; otherwise the change is uncontrollable.
6. Cost and Stability: Putting Uncertainty in a Cage
The cost of a probabilistic system must be modeled explicitly:
- Tiered scheduling: Simple requests go to small models or cache, complex requests escalate to large models, forming a cost gradient.
- Caching and idempotency: Apply semantic caching to reusable results; design idempotency keys for all write operations to avoid duplicate side effects from retries.
- Circuit breaking and degradation: When a tool call fails, degrade to “generate suggestions only, do not execute actions” so the system does not become entirely unavailable.
- Observability: Full-chain tracing (Trace) should record a summary of each model call’s input, token consumption, and tool latency. Logs and monitoring alerts can be built on general cloud capabilities (log services, monitoring and alerting, message queues, object storage, container platforms) without binding to a specific vendor.
7. Security Boundaries: A Lesson You Cannot Skip When Deploying Agents
Agents can perform real actions, so their risk level is higher than that of ordinary conversational applications. The following must be enforced:
- High-risk actions (deletion, transfers, external publishing) require mandatory human confirmation;
- Validate inputs and filter outputs on the tool side; do not trust model output by default;
- Desensitize sensitive data before it enters the context, and access data with least privilege;
- Keep full audit trails so every action decision can be traced after the fact.
8. Conclusion
The maturity of foundation capabilities is not the finish line but the starting point for engineering innovation. As model capabilities become homogeneous, team differentiation will come from task orchestration design, context governance, evaluation loops, and cost control. The suggested evolution path is: first use a single agent to validate the value hypothesis, then progressively split into multiple agents by responsibility complexity, with every step measured against quantifiable metrics. Baidu AI Cloud continues to invest in model services and engineering support, and developers can combine general cloud capabilities to steadily turn model capabilities into deliverable, operable business systems.
