← AI-Hands-on Multi-agent orchestration · Part 3 of 7Điều phối đa agent · Phần 3/7

One agent, one job — so how do three agents work together?Một agent, một việc — vậy ba agent phối hợp thế nào?

A single-purpose agent is easy to reason about but limited. This walkthrough adds an Orchestrator that discovers other agents dynamically and lets an LLM decide, at runtime, who should handle each request.

Một agent chuyên biệt dễ suy luận nhưng bị giới hạn. Video này thêm một Orchestrator tự động khám phá các agent khác và để chính LLM quyết định, ngay lúc chạy, ai nên xử lý từng yêu cầu.

Video demo: an Orchestrator routes a greeting request through a GreetingAgent, which itself calls TellTimeAgent.

Video demo: Orchestrator định tuyến yêu cầu chào hỏi qua GreetingAgent, và GreetingAgent tự gọi tiếp TellTimeAgent.

English

What problem does this solve?

Real operations need more than one skill at once: check the time, draft a greeting, look up a record, send a notification. Building one giant agent that knows how to do everything is brittle — every new capability means retraining or re-prompting the whole thing. The alternative is a set of small, single-purpose agents plus a router that knows who to call. This walkthrough continues studying the open-source theailanguage/a2a_samples reference implementation.

How the mechanism works

Three agents make up this demo: TellTimeAgent (only knows the time), GreetingAgent (writes greetings, but needs the time first), and an Orchestrator that talks to the user. On startup, the Orchestrator reads a small registry file of agent URLs and calls each one's discovery endpoint to build a live map of who exists and what they can do.

The Orchestrator does not use hard-coded if/else routing. It gives the LLM two tools — list known agents, and delegate a task to a named agent — and lets the model itself decide the plan. Ask for the time and it delegates straight to TellTimeAgent. Ask for a greeting and it delegates to GreetingAgent, which in turn calls TellTimeAgent on its own before composing a reply — one request triggering a two-hop chain.

Trade-offs and alternatives

The benefit is real modularity: adding a fourth agent means adding one line to a registry file, not touching the Orchestrator's code. The trade-off is that routing decisions now depend on an LLM call, which adds latency and a small chance of a wrong routing choice compared to deterministic if/else logic.

The alternative — one monolithic agent with every capability baked in — scales worse as the number of skills grows, and makes it harder to develop, test, or replace one capability independently of the others.

Conclusion

Small agents plus a registry plus LLM-driven delegation is a pattern that scales by addition, not by rewriting. It is also the shape most production multi-agent systems converge on once they outgrow a single do-everything bot.

Tiếng Việt

Vấn đề gì đang được giải quyết?

Vận hành thật cần nhiều hơn một kỹ năng cùng lúc: xem giờ, soạn lời chào, tra cứu hồ sơ, gửi thông báo. Xây một agent khổng lồ biết làm mọi thứ rất dễ vỡ — mỗi khả năng mới lại phải huấn luyện hoặc viết lại prompt cho toàn bộ. Hướng thay thế là một tập agent nhỏ, chuyên biệt, cộng với một bộ định tuyến biết gọi ai. Video này tiếp tục nghiên cứu bản triển khai tham chiếu mã nguồn mở theailanguage/a2a_samples.

Cơ chế hoạt động ra sao?

Demo này gồm ba agent: TellTimeAgent (chỉ biết xem giờ), GreetingAgent (viết lời chào, nhưng cần biết giờ trước), và một Orchestrator nói chuyện với người dùng. Khi khởi động, Orchestrator đọc một file danh sách nhỏ chứa địa chỉ các agent, rồi gọi endpoint khám phá của từng nơi để dựng một bản đồ sống về ai đang tồn tại và làm được gì.

Orchestrator không dùng luật if/else viết cứng. Nó đưa cho LLM hai công cụ — liệt kê các agent đã biết, và giao việc cho một agent cụ thể — rồi để chính mô hình tự quyết định kế hoạch. Hỏi giờ thì nó giao thẳng cho TellTimeAgent. Hỏi lời chào thì nó giao cho GreetingAgent, và GreetingAgent lại tự gọi tiếp TellTimeAgent trước khi soạn câu trả lời — một yêu cầu kích hoạt một chuỗi hai bước.

Đánh đổi và các hướng khác

Cái được là tính module thật sự: thêm agent thứ tư chỉ cần thêm một dòng vào file danh sách, không đụng vào code của Orchestrator. Cái đánh đổi là quyết định định tuyến giờ phụ thuộc vào một lệnh gọi LLM, tốn thêm độ trễ và có một xác suất nhỏ chọn sai so với luật if/else xác định.

Hướng thay thế — một agent nguyên khối nhồi hết mọi khả năng — mở rộng kém hơn khi số kỹ năng tăng lên, và khó phát triển, kiểm thử hay thay thế một khả năng riêng lẻ mà không ảnh hưởng các khả năng khác.

Kết luận

Agent nhỏ cộng danh sách đăng ký cộng ủy quyền do LLM dẫn dắt là mẫu hình mở rộng bằng cách cộng thêm, không phải viết lại. Đây cũng là hình dạng mà hầu hết hệ thống đa agent trong sản xuất hội tụ về, một khi vượt quá giới hạn của một con bot làm-mọi-thứ.