
Multi-Agent Workflows Thường Thất Bại — Đây Là Cách Engineer Cho Chúng Hoạt Động
Phần lớn thất bại của multi-agent workflows không đến từ model kém mà từ thiếu structure. GitHub Blog (2/2026) chỉ ra 3 pattern kỹ thuật: Typed Schemas tại mọi boundary, Action Schemas cho intent rõ ràng, và MCP làm enforcement layer. Hướng dẫn thực tế cho builders.
Tại Sao Multi-Agent Systems Vỡ Theo Cách Khó Debug
Một agent mở issue. Agent khác đóng nó. Downstream check thất bại vì nó assumes issue vẫn open. Bạn mất 2 giờ để tìm ra chuyện gì đã xảy ra.
Đây là một thất bại điển hình của multi-agent system. Và nguyên nhân không phải là model không đủ thông minh.
Theo GitHub Blog (2/2026), phần lớn multi-agent workflow failures xuất phát từ thiếu structure kiến trúc, không phải từ model yếu. Một khi nhiều agents cùng xử lý các tasks liên quan, implicit assumptions trở thành timebbombs.
Multi-agent systems về bản chất hoạt động như distributed systems: có state, ordering, interfaces, validation, và error handling — tất cả bị ẩn đi, cho đến khi có gì đó vỡ.
Failure Pattern #1: Natural Language Giữa Agents Là Messy
Khi agents trao đổi thông tin qua unstructured text hoặc inconsistent JSON:
- Field names thay đổi giữa các lần call
- Data types không match
- Formatting shifts
- Không có gì enforce consistency
Debugging trở thành "inspect logs và đoán" — thay vì "trace failure về đúng schema violation".
Fix #1: Typed Schemas Tại Mọi Boundary
Typed schemas thêm structure tại mỗi điểm handoff giữa agents. Agents truyền machine-checkable data, invalid messages fail fast, và downstream steps không phải guess payload nghĩa là gì.
Đây là cách GitHub mô tả starting point:
type UserProfile = {
id: number;
email: string;
plan: "free" | "pro" | "enterprise";
};
Khi schema này được enforce:
- Debugging chuyển từ "inspect logs và đoán" → "payload này vi phạm schema X"
- Schema violations được retry, repair, hoặc escalate — trước khi bad state lan xuống production
Nguyên tắc: Treat schema violations như contract failures. Không phải như warnings.
Ví dụ thực tế:
| Workflow | Benefit của Typed Schema |
|---|---|
| Support ticket triage | Ngăn agent pass incomplete ticket data xuống downstream |
| Lead qualification | Ensures required fields (email, company, plan) luôn present |
| Research pipeline | Output structure nhất quán cho summarization agent |
Failure Pattern #2: Vague Instructions Tạo Ambiguous Actions
"Analyze this issue and help the team take action" nghe có vẻ rõ ràng. Nhưng 4 agents có thể interpret thành 4 actions khác nhau — close, assign, escalate, hoặc không làm gì. Tất cả đều reasonable. Không cái nào automatable một cách safe.
Model intelligence không loại bỏ ambiguity — nó amplifies it. Model thông minh hơn có thể đưa ra argument thuyết phục hơn cho mỗi lựa chọn, làm cho vấn đề tệ hơn.
Fix #2: Action Schemas — Constrained Set of Valid Outcomes
Action schemas định nghĩa chính xác tập hợp actions được phép và structure của chúng:
const ActionSchema = z.discriminatedUnion("type", [
{ type: "request-more-info", missing: string[] },
{ type: "assign", assignee: string },
{ type: "close-as-duplicate", duplicateOf: number },
{ type: "no-action" }
]);
Với schema này, agent phải return đúng một valid action. Bất kỳ thứ gì khác đều fail validation và được retry hoặc escalate.
Kết quả thực tế:
- Automation gets safer — không có unexpected edge actions
- Consistency tăng lên — fewer human overrides
- Debugging trở nên trivial — bạn biết chính xác action nào đã được chọn
Không phải every step cần action schema — nhưng mọi outcome phải resolve về một set nhỏ, explicit actions.
Failure Pattern #3: Loose Tool Interfaces Gây Draft
Nếu tool interfaces không được định nghĩa chặt, agents sẽ:
- Tự bịa thêm fields không tồn tại
- Omit required inputs
- Drift across interfaces theo thời gian
Conventions không đủ trong production systems. Bạn cần enforcement.
Fix #3: MCP Là Enforcement Layer
Model Context Protocol (MCP) là layer biến typed schemas và action schemas từ conventions thành contracts.
MCP định nghĩa explicit input/output schemas cho mọi tool và resource — validation xảy ra trước khi execution:
{
"name": "create_issue",
"input_schema": { ... },
"output_schema": { ... }
}
Với MCP:
- Agents không thể invent fields không tồn tại
- Required inputs không thể bị omit
- Interface drift bị ngăn ở nguồn
- Bad state không bao giờ reach production systems
MCP không chỉ là hype — nó là infrastructure layer giải quyết vấn đề enforcement mà typed schemas và action schemas không thể giải quyết một mình.
Framework Thực Tế: Reliable Multi-Agent Design
Kết hợp 3 fixes trên thành một checklist thiết kế:
✅ Define schemas first — trước khi code bất kỳ agent nào
✅ Reduce actions to explicit allowed outcomes
✅ Validate every handoff — không cho phép messy payloads
✅ Separate planning from execution — agents có vai trò rõ ràng
✅ Log decisions and payloads — observability không phải optional
✅ Escalate on contract violations — không silently fail
3 Quy Tắc Vàng:
- Typed schemas = table stakes. Không có schema = không có reliability.
- Action schemas = every outcome must be explicit. "Something reasonable" là không đủ.
- MCP = enforcement, không phải convention. Contracts, không phải guidelines.
Use Cases Quan Trọng Nhất
Những workflow nào quan trọng nhất khi áp dụng 3 patterns này:
| Workflow | Điểm thất bại phổ biến | Fix quan trọng |
|---|---|---|
| Issue triage pipeline | Agents conflict về cùng issue | Action Schema |
| DevOps automation | Deployment state inconsistency | Typed Schema + MCP |
| Customer support routing | Double-handling cùng ticket | Action Schema |
| Content production pipeline | Format drift giữa agents | Typed Schema |
| Security review workflow | Missing required fields | MCP enforcement |
| Internal knowledge assistant | Context loss giữa agents | Typed Schema |
Những Lỗi Phổ Biến Cần Tránh
- Allow free-form outputs everywhere → không có gì có thể validate downstream
- Overuse natural-language-only instructions → ambiguity compound theo từng bước
- Skip validation → bad state lan xuống production silently
- Mix too many responsibilities into one agent → harder to debug, harder to constrain
- Give agents broad actions → unexpected side effects khi edge cases xuất hiện
Takeaway
Hãy treat agents như software components, không phải chatbots.
Multi-agent reliability không đến từ model thông minh hơn — nó đến từ kiến trúc có structure. Typed schemas tại mọi boundary. Action schemas cho mọi outcome. MCP làm enforcement layer.
Teams học nguyên tắc này sớm sẽ ship agent systems tốt hơn và nhanh hơn. Teams bỏ qua nó sẽ tiếp tục debug những failures mà trông giống model errors nhưng thực ra là architecture errors.
Nguồn: Multi-agent workflows often fail. Here's how to engineer ones that don't. — GitHub Blog