← AI-Hands-on AI agent protocols · Part 1 of 7Giao thức AI agent · Phần 1/7

How two AI agents that have never met still understand each otherHai AI agent chưa từng gặp nhau vẫn hiểu nhau bằng cách nào

Before agents can hand off work to each other, they need a shared handshake. This walkthrough of Google's Agent-to-Agent (A2A) protocol shows the two steps that make it possible: discovery and task execution.

Trước khi các agent có thể giao việc cho nhau, chúng cần một cái bắt tay chung. Video này đi qua giao thức Agent-to-Agent (A2A) của Google với hai bước cốt lõi: khám phá và thực thi tác vụ.

Video demo: an A2A client discovers a TellTimeAgent and completes a task end to end.

Video demo: một A2A client khám phá TellTimeAgent và hoàn thành một tác vụ từ đầu đến cuối.

English

What problem does this solve?

Once a company runs more than one AI agent, a new question shows up before any "intelligence" question: how does Agent A find Agent B, and how do they agree on a message format? Without a shared protocol, every integration between agents becomes bespoke glue code that breaks the moment either side changes.

A2A is a minimal answer to that question, not a framework. It defines two things only: how an agent announces itself, and how a task is sent and answered. This walkthrough studies and builds on the open-source theailanguage/a2a_samples reference implementation.

How the mechanism works

Discovery: every A2A server publishes a small "agent card" JSON file at a fixed path, /.well-known/agent.json — name, description, and declared capabilities. Any client can fetch that file first and confirm it found the right agent before sending anything.

Task execution: the client posts a task with a random ID and the message payload to /tasks/send. The server processes it, marks the task completed, and returns the full message history — the original question and the agent's answer together, so nothing has to be re-fetched separately.

Trade-offs and alternatives

The benefit is that any two A2A-compliant agents can talk without hand-written adapters. The trade-off is that this basic version is intentionally blocking and synchronous — the client waits for one JSON response, with no streaming and no built-in retry semantics. Later parts of this series show how the protocol evolves to add real intelligence, multi-agent routing, and streaming.

The alternative most teams reach for first is a direct REST or RPC call hard-coded between two specific services. That works for exactly two agents; it stops working the moment a third agent needs to join the conversation, because every pair now needs its own contract.

Conclusion

Discovery, then task execution — that is the entire contract. It looks almost too simple, but that simplicity is the point: a shared, minimal handshake is what lets agents from different teams, or different companies, interoperate without agreeing on anything else first.

Tiếng Việt

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

Khi một công ty vận hành nhiều hơn một AI agent, câu hỏi đầu tiên xuất hiện không phải là "agent có thông minh không" mà là: Agent A tìm Agent B bằng cách nào, và cả hai thống nhất định dạng tin nhắn ra sao? Không có giao thức chung, mỗi lần kết nối giữa hai agent lại trở thành code chắp vá riêng, dễ gãy khi một bên thay đổi.

A2A là câu trả lời tối giản cho câu hỏi đó, không phải một framework. Nó chỉ định nghĩa hai việc: agent tự giới thiệu như thế nào, và một tác vụ được gửi và trả lời ra sao. Video này nghiên cứu và xây dựng dựa trên bản triển khai tham chiếu mã nguồn mở theailanguage/a2a_samples.

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

Khám phá: mỗi server A2A công bố một file JSON nhỏ gọi là "danh thiếp agent" tại đường dẫn cố định /.well-known/agent.json — tên, mô tả, và khả năng đã khai báo. Bất kỳ client nào cũng có thể lấy file đó trước để xác nhận đúng agent cần tìm rồi mới gửi gì tiếp theo.

Thực thi tác vụ: client gửi một tác vụ kèm mã định danh ngẫu nhiên và nội dung tin nhắn tới /tasks/send. Server xử lý, đánh dấu tác vụ là completed, rồi trả về toàn bộ lịch sử hội thoại — câu hỏi gốc và câu trả lời trong cùng một lần, không cần lấy riêng lẻ.

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

Cái được là bất kỳ hai agent nào tuân theo A2A đều nói chuyện được mà không cần adapter viết tay. Cái đánh đổi là bản cơ bản này cố tình chạy đồng bộ và chặn — client chờ đúng một phản hồi JSON, chưa có streaming hay cơ chế thử lại tích hợp sẵn. Các phần sau của series sẽ cho thấy giao thức mở rộng thêm trí tuệ thật, định tuyến đa agent, và streaming.

Hướng thay thế phổ biến nhất là gọi REST hoặc RPC trực tiếp, viết cứng giữa hai dịch vụ cụ thể. Cách đó ổn với đúng hai agent; nó ngừng hoạt động ngay khi agent thứ ba cần tham gia, vì mỗi cặp lại cần hợp đồng riêng.

Kết luận

Khám phá rồi thực thi tác vụ — đó là toàn bộ hợp đồng. Nghe có vẻ đơn giản đến mức thừa, nhưng chính sự đơn giản đó là điểm mấu chốt: một cái bắt tay chung, tối giản, giúp các agent từ các đội khác nhau, hay công ty khác nhau, làm việc cùng nhau mà không cần thống nhất bất cứ điều gì khác trước.