Điều phối agentAgent orchestration

Chọn framework là chọn ai cầm lái.Choosing a framework is choosing who drives.

Sáu framework điều phối agent phổ biến, xếp theo một câu hỏi duy nhất: bước tiếp theo do code của bạn quyết định, hay do model? Six popular agent orchestration frameworks, arranged by a single question: is the next step decided by your code, or by the model?

Chọn cái nàoWhich one to pick

Trả lời theo thứ tự. Dừng ở câu đầu tiên bạn trả lời “có”.Answer in order. Stop at the first question you answer “yes” to.

Trước hết: có thể bạn không cần framework nàoFirst: you may not need a framework at all

Một lần gọi LLM, một chuỗi 2–4 bước viết bằng code thường, hoặc một agent với dưới khoảng 15–20 tool đều không cần framework. Vòng lặp dưới đây là đủ, đọc hiểu trong năm phút và gỡ lỗi bằng print. Chỉ nâng cấp khi cần resume, cần nhiều ngữ cảnh tách biệt, cần chạy song song có kiểm soát, hoặc cần tracing chuẩn cho cả đội. One LLM call, a 2–4 step chain in plain code, or a single agent with fewer than roughly 15–20 tools needs no framework. The loop below is enough, readable in five minutes, and debuggable with print. Upgrade only when you need resume, separate contexts, controlled parallelism, or standardized tracing across a team.

messages = [user_msg]
for _ in range(MAX_TURNS):              # always cap the turns
    resp = llm.call(messages, tools=TOOLS)
    if not resp.tool_calls:
        break
    for call in resp.tool_calls:
        messages.append(run_tool(call)) # return errors to the model
return resp.text
  1. Một lần gọi LLM hoặc một vòng tool-calling đã đủ?Is one LLM call or one tool-calling loop enough?

    Không dùng frameworkNo framework
  2. Đường đi biết trước, cần audit, phải dừng chờ người duyệt?Known path, needs audit, must pause for human approval?

  3. Một phần cố định, một phần cần model tự phán đoán?Partly fixed, partly needs model judgment?

  4. Model nên tự quyết gần như mọi bước?Should the model decide almost every step?

Phân vân giữa hai nhánh thì chọn nhánh gần phía code hơn. Nới quyền cho model dễ hơn nhiều so với thu hồi.Torn between two branches? Pick the one closer to code. Loosening the model’s control is far easier than taking it back.

Sáu frameworkThe six frameworks

Xếp theo vị trí trên trục, từ phía code sang phía model.Ordered by position on the axis, from the code end to the model end.

Nét liền: code quyết địnhSolid: code decides Nét đứt chuyển động: model quyết định lúc chạyMoving dashes: the model decides at runtime Chấm: dữ liệu hoặc chờ ngườiDots: data, or waiting on a human

Microsoft Agent Framework

Đồ thị tất địnhDeterministic graph
codemodel
Human Validate ok? Charge Notify Escalate yes no checkpoint → resume after sign-off

Bản kế nhiệm chính thức của AutoGen và Semantic Kernel (1.0 GA ngày 3/4/2026). Workflow là đồ thị executor với message có kiểu, checkpoint và bước chờ người duyệt; chạy trên .NET và Python.The official successor to AutoGen and Semantic Kernel (1.0 GA on April 3, 2026). Workflows are graphs of executors with typed messages, checkpoints, and human approval steps; runs on .NET and Python.

Đánh đổiTrade-off

Đổi sự gọn nhẹ và tính trung lập hệ sinh thái lấy type safety, telemetry và hỗ trợ dài hạn.Trades lightness and ecosystem neutrality for type safety, telemetry, and long-term support.

Dùng choUse for

  • Duyệt chi: kiểm tra, chờ quản lý duyệt, thanh toánSpend approval: validate, manager sign-off, pay
  • Claim bảo hiểm có thẩm định viênInsurance claims with a human assessor
  • Hệ thống nội bộ trên Azure, đội .NETInternal Azure systems, .NET teams

ĐượcGain

  • API ổn định, cam kết hỗ trợ dài hạnStable API, long-term support
  • .NET là công dân hạng nhất.NET is first-class
  • OpenTelemetry, MCP, A2A có sẵnOpenTelemetry, MCP, A2A built in

MấtLose

  • Mới, ít ví dụ cộng đồngNew; few community examples
  • Đường mượt nhất nghiêng về AzureSmoothest path leans Azure
  • Ví dụ SK/AutoGen cũ dễ gây nhầm APIOld SK/AutoGen examples cause API mix-ups

Dấu hiệu:Telltale sign: quy trình đã có trên giấy, có bước phê duyệt, và compliance sẽ hỏi “ai đã duyệt bước này”.the process already exists on paper, has approval steps, and compliance will ask “who approved this step”.

Đính chính ảnh gốc: không chỉ “workflow-based”, framework gồm cả lớp agent lẫn lớp workflow.Correction to the image: not only “workflow-based”; it has both an agent layer and a workflow layer.

LangGraph

Đồ thị tất địnhDeterministic graph
codemodel
node_a route node_b END yes no state

Đồ thị node–edge trên một state dùng chung. Code quyết định mọi chuyển bước; khi có checkpointer, state được lưu sau mỗi super-step nên dừng, chờ người duyệt rồi chạy tiếp được.A node–edge graph over one shared state. Code decides every transition; with a checkpointer, state is saved after each super-step, so the run can pause, wait for a reviewer, and resume.

Đánh đổiTrade-off

Đổi sự gọn nhẹ và tốc độ viết code lấy quyền kiểm soát từng bước cùng khả năng dừng rồi chạy tiếp.Trades lightness and coding speed for step-level control and the ability to pause and resume.

Dùng choUse for

  • Chờ nhân viên duyệt hoàn tiền rồi chạy tiếpPausing for a refund approval, then continuing
  • Pipeline chạy hàng giờ, cần resume khi sậpHours-long pipelines that resume after crashes
  • Vòng viết code, chạy test, sửa có trầnCapped write–test–fix coding loops

ĐượcGain

  • Mọi chuyển bước nằm trong code, test đượcEvery transition is code, unit-testable
  • HITL và resume gần như miễn phíHITL and resume almost for free
  • Không có lần gọi LLM ẩnNo hidden LLM calls

MấtLose

  • Đường cong học dốc: reducer, super-stepSteep curve: reducers, super-steps
  • Nhiều code khung cho bài toán nhỏHeavy scaffolding for small problems
  • Công cụ quan sát mạnh nhất là dịch vụ trả phíBest observability tool is paid

Dấu hiệu:Telltale sign: bạn vẽ được luồng lên bảng trắng, và nó phải dừng rồi chạy tiếp được.you can draw the flow on a whiteboard, and it must be able to pause and resume.

Đính chính ảnh gốc: checkpoint chỉ có khi compile đồ thị với một checkpointer.Correction to the image: checkpoints exist only if you compile the graph with a checkpointer.

Google ADK

LaiHybrid
codemodel
root ParallelAgent flight hotel activity state synth output_key → state

LlmAgent tự suy luận, được lồng trong các workflow agent (Sequential, Parallel, Loop) chạy theo logic cố định và không gọi LLM. Dữ liệu đi qua session state bằng output_key.Reasoning LlmAgents nested inside workflow agents (Sequential, Parallel, Loop) that run fixed logic and call no LLM. Data moves through session state via output_key.

Đánh đổiTrade-off

Đổi sự trung lập về hạ tầng lấy các khối điều phối tất định có sẵn và đường triển khai ngắn trên Google Cloud.Trades infrastructure neutrality for ready-made deterministic orchestration blocks and a short deploy path on Google Cloud.

Dùng choUse for

  • Tìm vé, khách sạn, hoạt động song song rồi tổng hợpParallel flight, hotel, activity search, then synthesis
  • Vòng soạn, phê bình, sửa tối đa N lầnDraft–critique–revise loops, max N times
  • Ứng dụng đã nằm trên Google Cloud và GeminiApps already on Google Cloud and Gemini

ĐượcGain

  • Phần điều phối không tốn tokenOrchestration costs no tokens
  • Ba khối luồng phủ phần lớn nhu cầuThree flow blocks cover most needs
  • Python, Java, Go, TS và giao thức A2APython, Java, Go, TS, plus A2A

MấtLose

  • Tích hợp sâu nhất giả định Google CloudDeepest integrations assume Google Cloud
  • Không có bước merge dựng sẵnNo built-in merge step
  • Trùng output_key là ghi đè nhauDuplicate output_keys overwrite each other

Dấu hiệu:Telltale sign: bạn muốn khung chạy cố định, nhưng từng ô bên trong cần một LLM phán đoán.you want fixed scaffolding, but each slot inside needs an LLM’s judgment.

Đính chính ảnh gốc: ADK không có node “Merge”; một agent phía sau đọc state để gộp kết quả.Correction to the image: ADK has no “Merge” node; a later agent reads state to combine results.

CrewAI

LaiHybrid
codemodel
manager opt-in researcher analyst writer report sequential = default

Một “đội” agent có role, goal, backstory. Task chạy tuần tự theo mặc định, hoặc qua một manager LLM nếu bật hierarchical. Flows là luồng hướng sự kiện, do code điều khiển, dành cho production.A “team” of agents with role, goal, and backstory. Tasks run sequentially by default, or through a manager LLM if hierarchical is enabled. Flows are event-driven, code-controlled pipelines for production.

Đánh đổiTrade-off

Đổi quyền kiểm soát chi tiết luồng chạy lấy tốc độ dựng một đội agent theo vai trò.Trades fine-grained control of execution for the speed of assembling a role-based agent team.

Dùng choUse for

  • Pipeline nội dung: nghiên cứu, viết, biên tậpContent pipelines: research, write, edit
  • Báo cáo thị trường từ nhiều nguồn webMarket reports from many web sources
  • Prototype multi-agent trong một buổi chiềuA multi-agent prototype in one afternoon

ĐượcGain

  • Dựng nhanh nhất trong sáu frameworkFastest of the six to stand up
  • Mô hình vai trò dễ giải thíchRole model is easy to explain
  • Memory, structured output có sẵnMemory and structured output built in

MấtLose

  • Hierarchical thêm một lần gọi manager mỗi vòngHierarchical adds a manager call each round
  • Hành vi phụ thuộc prompt hơn vẻ ngoài “đội ngũ”Behavior hinges on prompts, not the “team” framing
  • Manager phân việc sai thì khó gỡ lỗiHard to debug a manager’s bad delegation

Dấu hiệu:Telltale sign: bạn mô tả hệ thống bằng chức danh trước khi nghĩ tới luồng dữ liệu.you describe the system in job titles before thinking about data flow.

Đính chính ảnh gốc: ảnh vẽ manager, nhưng mặc định là sequential; hierarchical phải bật rõ và cần manager_llm.Correction to the image: it shows a manager, but the default is sequential; hierarchical must be enabled and needs manager_llm.

OpenAI Agents SDK

Model tự điều phốiModel-driven
codemodel
handoff triage billing support agent as tool orchestrator call result sub_agent

API tối giản: agent, handoff, guardrail, session, tracing. Model tự quyết chuyển hẳn quyền cho agent khác (handoff) hay gọi agent khác như một tool rồi giữ quyền trả lời (agent-as-tool).A minimal API: agents, handoffs, guardrails, sessions, tracing. The model decides whether to hand control to another agent (handoff) or call it like a tool and keep answering itself (agent-as-tool).

Đánh đổiTrade-off

Đổi tính tất định của luồng chạy lấy một API tối giản nơi model tự quyết giao việc cho ai.Trades deterministic execution for a minimal API where the model decides whom to hand work to.

Dùng choUse for

  • Chatbot CSKH nhiều bộ phận chuyên tráchSupport bots with specialist desks
  • Trợ lý nội bộ định tuyến HR, IT, pháp chếInternal assistants routing to HR, IT, legal
  • Voice agent chuyển người phụ trách giữa cuộc gọiVoice agents transferring mid-call

ĐượcGain

  • API nhỏ nhất, chạy được trong vài phútSmallest API, running in minutes
  • Tracing có sẵn, không cần cấu hìnhTracing built in, zero setup
  • Guardrail là khái niệm hạng nhấtGuardrails are first-class

MấtLose

  • Cùng đầu vào có thể đi hai nhánh khác nhauSame input can take different branches
  • Session lưu hội thoại, không lưu tiến độSessions keep chat, not process progress
  • Chuỗi handoff dài làm ngữ cảnh phìnhLong handoff chains bloat context

Dấu hiệu:Telltale sign: bài toán nghe giống tổng đài, “chuyển máy cho bộ phận phù hợp”.the problem sounds like a call center: “transfer me to the right department”.

Claude Agent SDK

Model tự điều phốiModel-driven
codemodel
gather act verify result repeat until done subagents tools · bash · MCP

Harness chạy Claude Code (vòng điều khiển bao quanh model), đóng gói thành SDK. Agent có file system, bash, tool, MCP và tự lặp: thu thập ngữ cảnh, hành động, kiểm chứng, lặp lại đến khi đạt.The harness behind Claude Code, packaged as an SDK. The agent gets a file system, bash, tools, and MCP, and loops on its own: gather context, act, verify, repeat until done.

Đánh đổiTrade-off

Đổi khả năng dự đoán chi phí và đường đi lấy một agent tự chủ, tự kiểm chứng, đã thử lửa ở quy mô Claude Code.Trades predictable cost and path for an autonomous, self-verifying agent proven at Claude Code scale.

Dùng choUse for

  • Sửa bug trong repo thật, có chạy testFixing bugs in a real repo, with tests
  • Đọc hàng trăm tài liệu, viết báo cáo có nguồnReading hundreds of docs into a cited report
  • SRE: đọc log, chạy lệnh chẩn đoánSRE: read logs, run diagnostics

ĐượcGain

  • Harness đã chạy thực tế, có nén ngữ cảnhBattle-tested harness with compaction
  • Tool file và shell có sẵnFile and shell tools built in
  • Sub-agent, hooks, permissionSub-agents, hooks, permissions

MấtLose

  • Chi phí và thời gian khó đoánCost and time are hard to predict
  • Gắn với model ClaudeTied to Claude models
  • Agent có bash là bề mặt tấn công lớnAn agent with bash is a big attack surface

Dấu hiệu:Telltale sign: số bước không biết trước, và người làm việc này sẽ cần một máy tính có terminal.the number of steps is unknown, and a human doing this job would need a computer with a terminal.

Bảng đánh đổiTrade-off table

Đọc theo hàng. Hàng đầu tiên quyết định gần hết các hàng còn lại.Read by rows. The first row determines most of the others.

MS Agent Fw LangGraph Google ADK CrewAI OpenAI SDK Claude SDK
Ai quyết định bước tiếpWho decides next Code (workflow)Code (workflow) Code (đồ thị)Code (graph) Khung cố định, LLM bên trongFixed scaffold, LLM inside Sequential hoặc manager LLMSequential or manager LLM LLM (handoff)LLM (handoffs) LLM (agent loop)LLM (agent loop)
Dừng rồi chạy tiếpPause and resume Checkpoint trong workflowWorkflow checkpoints Mạnh, checkpointer là lõiStrong; checkpointer is core Qua session state, tuỳ backendVia session state, backend-dependent Flows có; Crews yếuFlows yes; Crews weak Lưu hội thoại, không lưu tiến độStores chat, not progress Resume session, nén ngữ cảnhSession resume, compaction
Token phát sinhExtra token cost Không có call ẩnNo hidden calls Không có call ẩnNo hidden calls Workflow agent không gọi LLMWorkflow agents call no LLM Hierarchical: +1 call mỗi vòngHierarchical: +1 call per round Mỗi handoff thêm lượt modelEach handoff adds turns Cao, model chọn số vòngHigh; model picks turn count
Quan sát, gỡ lỗiObservability OpenTelemetry LangSmith (trả phí)LangSmith (paid) Dev UI, Cloud TraceDev UI, Cloud Trace Trung bình, lỗi nằm trong suy luậnMedium; bugs live in reasoning Tracing có sẵnBuilt-in tracing Hooks, log tool callHooks, tool-call logs
Ràng buộc nhà cung cấpVendor pull Nghiêng AzureLeans Azure KhôngNone Nghiêng Gemini, GCPLeans Gemini, GCP KhôngNone Nghiêng OpenAILeans OpenAI Model ClaudeClaude models
Tới bản chạy đầuTime to first run Trung bìnhMedium ChậmSlow Trung bìnhMedium Nhanh nhấtFastest NhanhFast NhanhFast

Anti-patternsAnti-patterns

Sai lầmMistakeVì sao saiWhy it’s wrongSửa thế nàoFix
Multi-agent cho việc một agent làm đượcMulti-agent for one-agent work Thêm lần gọi model, thêm điểm hỏng, mất ngữ cảnh khi chuyển giaoMore model calls, more failure points, context lost at handoff Bắt đầu một agent; chỉ tách khi đo được ngữ cảnh quá tảiStart with one; split only when you measure overload
LLM định tuyến quy trình đã biết thứ tựLLM routing a known-order process Trả tiền và chịu rủi ro sai đường cho quyết định code làm miễn phíPaying for, and risking errors on, a decision code makes for free Edge cố định, SequentialAgent, Process.sequentialFixed edges, SequentialAgent, Process.sequential
Vòng lặp không có trầnUncapped loops Agent lặp đến khi hết ngân sách hoặc hết giờThe agent loops until budget or clock runs out max_iterations, recursion_limit, max_turns
Handoff khi cần kết quả quay vềHandoff when you need the result back Agent mới tiếp quản, orchestrator mất quyền tổng hợpThe new agent takes over; the orchestrator can’t synthesize Dùng agent-as-toolUse agent-as-tool
Bước duyệt mà không có checkpointApproval step without a checkpoint Người duyệt trả lời sau hai ngày, tiến trình đã chết, mất tiến độThe reviewer replies two days later; the process is dead, progress lost Checkpointer bền (Postgres), bước duyệt thành node riêngDurable checkpointer (Postgres), approval as its own node
Agent có bash chạy thẳng trên máy thậtAgent with bash on a real machine Một lệnh sai là mất dữ liệu; prompt injection thành thực thi lệnhOne bad command loses data; prompt injection becomes execution Sandbox, permission mặc định chặn, hook chặn lệnh nguy hiểmSandbox, default-deny permissions, blocking hooks

Ba câu cần nhớThree things to remember