Workflow, Agent hay Multi-agent Framework?
Chọn mức tự chủ và abstraction bằng failure model, state, control flow và observability—không bằng độ nổi tiếng của framework.
Bắt đầu bằng deterministic workflow; chỉ trao quyền chọn bước cho model khi variance của task tạo giá trị lớn hơn chi phí kiểm soát.
Những điều cần nắm chắc
Workflow có code path định trước; agent tự quyết định process và tool usage.
Multi-agent thêm coordination state, failure propagation và synthesis cost.
Framework được chọn sau khi đã biết state machine và reliability requirement.
Repository cũ có thể còn giá trị giáo dục nhưng không đồng nghĩa phù hợp production mới.
Nội dung bài viết
Complexity ladder trước framework matrix
Anthropic đề xuất đi từ augmented LLM đến prompt chaining, routing, parallelization, orchestrator-workers rồi mới tới autonomous agent. Mỗi nấc đổi latency, cost và failure surface. Nếu task phân rã ổn định, workflow code thường dễ test và vận hành hơn agent tự lập kế hoạch.
Multi-agent phù hợp khi subtasks thật sự độc lập hoặc cần context/role chuyên biệt. Nếu các worker liên tục chia sẻ mutable state hoặc sửa cùng artifact, coordination overhead có thể lớn hơn lợi ích song song.
Đọc framework qua primitive nó sở hữu
LangGraph tập trung graph state, durable execution và human-in-the-loop cho workflow dài. Semantic Kernel cung cấp agent abstraction, plugins và các orchestration pattern. AutoGen có đóng góp lớn về event-driven multi-agent, nhưng repository hiện khuyến nghị dự án mới xem Microsoft Agent Framework. CrewAI đưa role/task/crew lên abstraction cao hơn.
Không framework nào loại bỏ nhu cầu định nghĩa tool schema, permission, state ownership, termination và eval. Framework chỉ quyết định phần boilerplate nào được đóng gói và phần behavior nào trở nên implicit.
Swarm là case study về lifecycle của nguồn tham khảo
OpenAI Swarm minh họa hai primitive dễ hiểu: agent và handoff. Repository tự ghi rõ đây là educational/experimental và đã được thay thế cho production bởi OpenAI Agents SDK. Một source catalog tốt phải lưu cả status này, không chỉ URL.
Bài học tổng quát: luôn kiểm tra maintenance mode, migration note, experimental label và ngày cập nhật trước khi biến sample thành nền tảng kiến trúc.
Framework selection checklist
Vẽ state machine không phụ thuộc vendor trước: run, step, observation, checkpoint, approval, cancel và terminal states. Sau đó đánh giá framework theo durability, replay, tracing, interrupt/resume, TypeScript support, deployment model và khả năng thoát framework.
- Control flow cố định hay model-driven?
- State ephemeral, thread-scoped hay durable?
- Có cần parallel, handoff hay evaluator-optimizer?
- Ai sở hữu retry, idempotency và compensation?
- Trace có đủ để tái hiện một failure production không?
Hướng triển khai đang hội tụ: agentic ở decision point, deterministic ở execution path
Các hệ sinh thái lớn đang hội tụ ở cùng một nguyên tắc: giữ model ở nơi cần semantic judgment, còn validation, permission, retry, state transition và artifact verification nằm trong code hoặc runtime. OpenAI gọi rõ ranh giới giữa direct tool calls và programmatic tool calling; Anthropic khuyến nghị tăng complexity theo nhu cầu; LangGraph và AutoGen đưa state, termination và coordination thành primitive quan sát được.
Một stack hiệu quả thường có bốn lớp: skills hoặc dynamic context để chỉ nạp expertise cần thiết; tools/MCP để chuẩn hóa capability; durable workflow để checkpoint và resume; eval/trace để chứng minh accuracy, efficiency và side effect. Multi-agent chỉ là topology tùy chọn ở trên bốn lớp này, không phải đích đến mặc định.
- Dynamic context thay cho mega-prompt luôn nạp mọi thứ.
- Bounded code path cho filtering, joining, validation và aggregation.
- Model judgment tại routing, exception handling và final synthesis.
- Human approval trước external write hoặc hành động khó đảo ngược.
- Eval dataset và trace review đi cùng mỗi thay đổi prompt, skill hoặc tool.
Code & cấu trúc tham khảo
Decision sequence không phụ thuộc vendor
1Known steps + strict SLA -> deterministic workflow2Distinct input categories -> router + specialized workflows3Independent bounded subtasks -> parallel workers + deterministic synthesis4Unknown task decomposition -> orchestrator-workers with budgets5Long-running mutable process -> durable graph/runtime6High-risk external side effects -> approval + idempotency + audit trailTakeaway: Chọn topology trước, chọn library sau; nếu đổi framework mà mental model sụp đổ, abstraction ban đầu chưa đủ rõ.
Tài liệu đọc thêm
Repo, đặc tả và bài viết gốc để đi sâu sau bài học.
Anthropic — Building effective agents
Complexity ladder và các workflow pattern composable.
LangGraph
Low-level orchestration cho long-running stateful agents.
Microsoft Semantic Kernel Agent Framework
Agent abstraction, plugins và orchestration patterns.
Microsoft AutoGen
Kiến trúc multi-agent và trạng thái maintenance hiện tại.
OpenAI Swarm
Case study educational về agent handoff; không dùng cho production mới.
CrewAI documentation
Role/task/crew abstraction trong ecosystem multi-agent.
OpenAI — Programmatic Tool Calling
Chạy bounded tool-heavy stage bằng code và trả structured result nhỏ hơn.
LangGraphJS architecture specification
Channels, checkpointer và Pregel execution engine phía dưới graph API.
AutoGen architecture and AgentChat
AgentChat abstraction trên event-driven AutoGen Core.
Google Agent Development Kit
Open-source runtime và patterns để xây, đánh giá, triển khai agent.