← AI-Hands-on Enterprise architecture · Part 7 of 7Kiến trúc doanh nghiệp · Phần 7/7

From six loose demos to one production-shaped frameworkTừ sáu demo rời rạc thành một khung sườn dáng dấp sản xuất

A2A, MCP, streaming, and Docker each solved one problem in isolation. This final part combines all of it into a single, layered structure — the shape most real multi-agent systems eventually converge on.

A2A, MCP, streaming, và Docker mỗi thứ đã giải quyết một vấn đề riêng lẻ. Phần cuối này gộp tất cả thành một cấu trúc nhiều lớp — hình dạng mà hầu hết hệ thống đa agent thật sự hội tụ về.

Video demo: a layered server/agents/client/utilities structure with hybrid A2A + MCP discovery and a new Website Builder agent.

Video demo: cấu trúc phân lớp server/agents/client/utilities với khám phá lai A2A + MCP và một agent Website Builder mới.

English

What problem does this solve?

Each earlier part in this series proved one mechanism in isolation: discovery, real reasoning, multi-agent routing, tool access, streaming, deployment. None of them alone is what a business actually ships. The real question this part answers is what an enterprise-shaped codebase looks like once all of those mechanisms have to coexist and stay maintainable. This walkthrough continues studying the open-source theailanguage/a2a_samples reference implementation.

How the mechanism works

The codebase is reorganized into clear layers — server, agents, client, and utilities — each with one responsibility, instead of one flat folder of scripts. Discovery becomes hybrid: the same mechanism can find both A2A agents and MCP servers, so a Host Agent doesn't need two separate discovery code paths.

Two smaller but telling upgrades round this out. A new Website Builder agent shows the pattern extending to a genuinely different capability — generating HTML/CSS on request — without changing how the Host Agent talks to it. And MCP itself is upgraded from local stdio to running over HTTP with Server-Sent Events, so tool access is no longer limited to processes on the same machine. Initialization also moves to an explicit async create() step, so loading network configuration never blocks the main thread on startup.

Trade-offs and alternatives

The benefit is a structure a team can actually extend without stepping on each other — a new agent or a new tool has an obvious place to live. The trade-off is more upfront structure than a single working prototype needs; this layering earns its cost once more than one or two agents exist, not before.

The alternative — keeping every version as its own loose script, the way each earlier part in this series did — is the fastest way to learn a mechanism in isolation, which is exactly why the series was built that way. It stops being the right choice the moment the goal shifts from learning the protocol to shipping something a team maintains together.

Conclusion

Across seven parts, this series moved from a hard-coded reply to a discovery handshake, to real reasoning, to multi-agent routing, to tool access, to live streaming, to a deployed container, and finally to a layered structure that holds all of it. That progression — not any single mechanism — is the actual lesson: production-grade agent systems are built in exactly this kind of increments, not assembled whole on day one.

Tiếng Việt

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

Mỗi phần trước trong series này chứng minh một cơ chế riêng lẻ: khám phá, suy luận thật, định tuyến đa agent, truy cập công cụ, streaming, triển khai. Không phần nào trong số đó, đứng một mình, là thứ một doanh nghiệp thực sự đưa ra sản phẩm. Câu hỏi thật sự phần này trả lời là một codebase dáng dấp doanh nghiệp trông ra sao khi tất cả các cơ chế đó phải cùng tồn tại và vẫn dễ bảo trì. 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?

Codebase được tổ chức lại thành các lớp rõ ràng — server, agents, client, và utilities — mỗi lớp một trách nhiệm, thay vì một thư mục phẳng chứa toàn bộ script. Khám phá trở thành lai: cùng một cơ chế tìm được cả agent A2A lẫn máy chủ MCP, nên Host Agent không cần hai luồng code khám phá riêng biệt.

Hai nâng cấp nhỏ hơn nhưng đáng chú ý hoàn thiện bức tranh này. Một agent Website Builder mới cho thấy mẫu hình mở rộng sang một khả năng thực sự khác — sinh HTML/CSS theo yêu cầu — mà không cần đổi cách Host Agent nói chuyện với nó. Và chính MCP được nâng cấp từ stdio cục bộ sang chạy qua HTTP với Server-Sent Events, nên truy cập công cụ không còn giới hạn ở các tiến trình trên cùng một máy. Việc khởi tạo cũng chuyển sang một bước create() bất đồng bộ tường minh, để việc nạp cấu hình mạng không bao giờ chặn luồng chính khi khởi động.

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

Cái được là một cấu trúc mà một đội thực sự có thể mở rộng mà không giẫm chân nhau — một agent mới hay công cụ mới đều có chỗ rõ ràng để đặt vào. Cái đánh đổi là nhiều cấu trúc ban đầu hơn mức một bản demo đơn lẻ cần; sự phân lớp này chỉ đáng giá khi có nhiều hơn một hai agent tồn tại, chưa cần trước đó.

Hướng thay thế — giữ mỗi phiên bản là một script rời rạc riêng, như cách từng phần trước của series đã làm — là cách nhanh nhất để học một cơ chế riêng lẻ, và đó chính xác là lý do series được xây dựng như vậy. Nó ngừng là lựa chọn đúng ngay khi mục tiêu chuyển từ học giao thức sang giao một thứ mà cả đội cùng bảo trì.

Kết luận

Qua bảy phần, series này đi từ một câu trả lời cứng đến cái bắt tay khám phá, đến suy luận thật, đến định tuyến đa agent, đến truy cập công cụ, đến streaming trực tiếp, đến một container đã triển khai, và cuối cùng đến một cấu trúc phân lớp giữ tất cả những điều đó. Chính hành trình đó — không phải một cơ chế đơn lẻ nào — mới là bài học thật sự: hệ thống agent đạt chuẩn sản xuất được xây dựng đúng theo từng bước nhỏ như vậy, không phải lắp ráp trọn vẹn ngay từ ngày đầu.