A2A Protocol - Giao thức Agent-to-Agent cho Hệ thống Multi-Agent AI

Posted on: 4/13/2026 10:03:37 PM

Table of contents

  1. 1. A2A là gì và tại sao thế giới AI cần nó?
    1. Điểm mấu chốt
  2. 2. Hành trình phát triển của A2A
    1. Tại sao Google trao A2A cho Linux Foundation?
  3. 3. Kiến trúc kỹ thuật tổng quan
    1. 3.1. Bốn khả năng cốt lõi
    2. 3.2. Nguyên tắc thiết kế
  4. 4. Agent Card - "Danh thiếp" của AI Agent
    1. So sánh Agent Card vs MCP Server Card
    2. 4.1. Signed Agent Cards (v0.3)
  5. 5. Task Lifecycle - Vòng đời của một tác vụ
    1. 5.1. Cấu trúc Task Object
    2. 5.2. Messages và Parts - Giao tiếp đa phương tiện
      1. Tại sao multimodal Parts quan trọng?
    3. 5.3. Artifacts - Output có cấu trúc
  6. 6. JSON-RPC Methods - API cốt lõi
    1. 6.1. Task Management
    2. 6.2. Danh sách đầy đủ các methods
  7. 7. Streaming và Push Notifications
    1. 7.1. SSE Streaming Events
    2. 7.2. Push Notifications cho Long-running Tasks
      1. Lưu ý khi dùng Push Notifications
  8. 8. A2A + MCP: Bộ đôi hoàn hảo cho Multi-Agent Systems
    1. Quy tắc vàng khi chọn giao thức
  9. 9. Bảo mật và xác thực
    1. 9.1. Security Schemes
    2. 9.2. Extended Agent Cards
  10. 10. Production Patterns cho A2A
    1. Pattern 1: Hub-and-Spoke
    2. Pattern 2: Pipeline Chain
    3. Pattern 3: Peer-to-Peer Negotiation
    4. Pattern 4: Hierarchical Delegation
      1. Anti-pattern cần tránh
  11. 11. Triển khai A2A Agent với Python
    1. 11.1. Client Agent gọi Remote Agent
  12. 12. gRPC Binding - Hiệu năng cao cho Internal Services
    1. Khi nào dùng gRPC?
  13. 13. Hệ sinh thái và tương lai
    1. 13.1. Tích hợp với các AI Frameworks
    2. 13.2. AAIF - Tương lai hội tụ MCP + A2A
    3. 13.3. Xu hướng 2026-2027
  14. 14. Kết luận
    1. Bắt đầu ngay hôm nay
A2A Protocol Multi-Agent Google Agentic AI System Architecture

1. A2A là gì và tại sao thế giới AI cần nó?

Agent-to-Agent Protocol (A2A) là giao thức mở do Google giới thiệu vào tháng 4/2025, cho phép các AI agent từ những nền tảng khác nhau tự phát hiện, giao tiếp và phối hợp với nhau mà không cần biết chi tiết nội bộ của agent kia. Nếu MCP là "USB-C kết nối agent với công cụ", thì A2A chính là HTTP của thế giới agent - giao thức cho phép các agent "nói chuyện" với nhau.

Hãy tưởng tượng bạn có một agent Claude chuyên phân tích code, một agent Gemini chuyên tìm kiếm thông tin, và một agent chuyên quản lý lịch trình. Trước A2A, việc phối hợp các agent này đòi hỏi custom integration cho từng cặp - tạo ra bài toán N x N integration kinh điển. A2A giải quyết điều đó bằng một giao thức chuẩn duy nhất.

150+Tổ chức hỗ trợ A2A
v0.3Phiên bản mới nhất (07/2025)
3Protocol Bindings (HTTP, SSE, gRPC)
7Task States trong lifecycle

Điểm mấu chốt

A2A giải quyết bài toán mà MCP không cover: giao tiếp ngang hàng giữa các agent. MCP kết nối agent với tools/data (trục dọc), A2A kết nối agent với agent (trục ngang). Trong hệ thống production thực tế, bạn sẽ cần cả hai giao thức hoạt động song song.

2. Hành trình phát triển của A2A

A2A có tốc độ adoption ấn tượng nhờ sự hậu thuẫn của Google và hệ sinh thái rộng lớn các đối tác công nghệ:

Tháng 4/2025
Google công bố A2A Protocol với hơn 50 đối tác ban đầu bao gồm Atlassian, Salesforce, SAP, PayPal, LangChain, MongoDB. Spec v0.1 sử dụng JSON-RPC 2.0 over HTTP.
Tháng 6/2025
Google trao A2A cho Linux Foundation, chuyển từ dự án của Google thành chuẩn mở trung lập. Repository chính thức chuyển sang github.com/a2aproject/A2A.
Tháng 7/2025
Ra mắt A2A v0.3 - bổ sung gRPC binding, Signed Agent Cards cho bảo mật nâng cao, mở rộng Python SDK. Số tổ chức hỗ trợ vượt 150.
Tháng 12/2025
Agentic AI Foundation (AAIF) thành lập dưới Linux Foundation. Cả MCP và A2A đều nằm dưới AAIF với founding members: Anthropic, OpenAI, Google, Microsoft, AWS, Block.
Tháng 4/2026
A2A ecosystem trưởng thành: tích hợp sâu với Vertex AI Agent Engine, LangGraph, CrewAI. Nhiều enterprise bắt đầu triển khai A2A trong production.

Tại sao Google trao A2A cho Linux Foundation?

Cùng logic với Anthropic trao MCP: một giao thức mở cần governance trung lập để được tin dùng. Khi cả MCP và A2A cùng nằm dưới AAIF, hai giao thức chuyển từ "sản phẩm của từng công ty" thành "chuẩn chung của ngành" - tạo tiền đề cho convergence trong tương lai.

3. Kiến trúc kỹ thuật tổng quan

A2A sử dụng mô hình Client-Remote dựa trên JSON-RPC 2.0. Điểm khác biệt then chốt so với MCP: A2A coi mỗi agent là một "hộp đen" (opaque) - client agent không cần biết agent kia được xây dựng bằng framework nào, dùng LLM gì, hay có kiến trúc nội bộ ra sao.

graph LR
    A["Client Agent"] -->|"1. Discover"| B["Agent Card /.well-known/agent.json"]
    A -->|"2. SendMessage"| C["Remote Agent"]
    C -->|"3. Status Updates"| A
    C -->|"4. Artifacts"| A
    C -->|"MCP"| D["Tools & Data"]
    A -->|"MCP"| E["Tools & Data"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style C fill:#4285f4,stroke:#fff,color:#fff
    style D fill:#4CAF50,stroke:#fff,color:#fff
    style E fill:#4CAF50,stroke:#fff,color:#fff

Hình 1: Kiến trúc A2A - Client Agent discover và giao tiếp với Remote Agent, mỗi agent dùng MCP để truy cập tools

3.1. Bốn khả năng cốt lõi

A2A Protocol được thiết kế xoay quanh bốn khả năng chính:

Khả năngMô tảCơ chế
Capability DiscoveryAgent tự quảng cáo khả năng của mìnhAgent Cards (JSON) tại endpoint chuẩn
Task ManagementQuản lý vòng đời task từ tạo đến hoàn thànhTask object với 7 states, artifacts
CollaborationTrao đổi context, instructions giữa agentsMessages với multi-modal Parts
UX NegotiationThương lượng định dạng output phù hợpacceptedOutputModes, iframes, forms

3.2. Nguyên tắc thiết kế

  • Opaque Agents: Agent không cần tiết lộ nội bộ - framework, LLM, hay logic xử lý đều được giữ kín
  • Enterprise-grade Security: Hỗ trợ OAuth 2.0, API Key, Mutual TLS, OpenID Connect
  • Modality Agnostic: Hỗ trợ text, file, structured data, iframe - không bị giới hạn ở text thuần
  • Long-running Tasks: Thiết kế cho cả tác vụ nhanh (ms) lẫn tác vụ kéo dài (giờ, ngày)

4. Agent Card - "Danh thiếp" của AI Agent

Agent Card là thành phần quan trọng nhất cho capability discovery. Mỗi agent publish một JSON document tại /.well-known/agent.json, mô tả đầy đủ khả năng và cách kết nối.

{
  "name": "code-review-agent",
  "description": "Chuyên phân tích code, tìm bug, đề xuất refactoring",
  "version": "2.1.0",
  "provider": {
    "name": "DevTools Inc",
    "url": "https://devtools.example.com",
    "contact": "support@devtools.example.com"
  },
  "capabilities": {
    "streaming": true,
    "pushNotifications": true,
    "extendedAgentCard": true
  },
  "skills": [
    {
      "id": "code-review",
      "name": "Code Review",
      "description": "Phân tích code quality, security vulnerabilities, performance issues",
      "inputSchema": {
        "type": "object",
        "properties": {
          "language": { "type": "string", "enum": ["python", "typescript", "go", "rust"] },
          "code": { "type": "string" },
          "reviewType": { "type": "string", "enum": ["security", "performance", "quality"] }
        },
        "required": ["language", "code"]
      }
    }
  ],
  "interfaces": [
    { "type": "JSON-RPC", "url": "https://agent.devtools.example.com/a2a" }
  ],
  "securitySchemes": {
    "oauth2": {
      "type": "oauth2",
      "flows": {
        "clientCredentials": {
          "tokenUrl": "https://auth.devtools.example.com/token",
          "scopes": { "agent:invoke": "Invoke agent capabilities" }
        }
      }
    }
  },
  "security": [["oauth2"]]
}

So sánh Agent Card vs MCP Server Card

Agent Card mô tả skills (khả năng cao cấp) của agent, trong khi MCP Server Card mô tả tools (hành động cụ thể). Ví dụ: A2A Agent Card nói "tôi biết review code", còn MCP Server Card nói "tôi có tool run_linter, tool check_types". Agent Card là abstraction level cao hơn - phù hợp cho giao tiếp giữa các entity thông minh.

4.1. Signed Agent Cards (v0.3)

Từ version 0.3, A2A hỗ trợ Signed Agent Cards - agent card được ký bằng cryptographic signature để đảm bảo tính xác thực. Điều này quan trọng trong môi trường enterprise nơi bạn cần chắc chắn agent card không bị giả mạo.

{
  "name": "verified-finance-agent",
  "signature": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "provider": {
    "name": "FinCorp",
    "verified": true
  }
}

5. Task Lifecycle - Vòng đời của một tác vụ

Task là đơn vị công việc cơ bản trong A2A. Mỗi task đi qua một state machine rõ ràng với 7 trạng thái:

stateDiagram-v2
    [*] --> WORKING: SendMessage
    WORKING --> COMPLETED: Task done
    WORKING --> FAILED: Error occurred
    WORKING --> CANCELED: CancelTask
    WORKING --> REJECTED: Agent refuses
    WORKING --> INPUT_REQUIRED: Need more info
    WORKING --> AUTH_REQUIRED: Need auth
    INPUT_REQUIRED --> WORKING: User provides input
    AUTH_REQUIRED --> WORKING: Auth completed
    COMPLETED --> [*]
    FAILED --> [*]
    CANCELED --> [*]
    REJECTED --> [*]

Hình 2: State Machine của Task - 7 trạng thái trong vòng đời task A2A

5.1. Cấu trúc Task Object

{
  "id": "task-abc-123",
  "contextId": "conversation-xyz",
  "status": {
    "state": "WORKING",
    "timestamp": "2026-04-13T10:30:00Z"
  },
  "messages": [
    {
      "role": "user",
      "parts": [
        { "text": "Phân tích file main.py và tìm security vulnerabilities" }
      ]
    }
  ],
  "artifacts": [],
  "metadata": {
    "priority": "high",
    "requestedBy": "orchestrator-agent"
  }
}

5.2. Messages và Parts - Giao tiếp đa phương tiện

Mỗi Message chứa một mảng Parts - các đơn vị nội dung đa dạng:

Part TypeMô tảUse Case
TextPartNội dung text thuầnInstructions, responses, analysis results
FilePartFile reference với mediaTypeUpload code files, documents, images
DataPartJSON structured dataForms, tables, API responses, configs
IframePartEmbedded UI component URLInteractive dashboards, approval forms

Tại sao multimodal Parts quan trọng?

Trong thực tế, agents cần trao đổi nhiều hơn text. Một agent phân tích hình ảnh cần gửi file ảnh. Một agent tạo báo cáo cần trả về structured data. Một agent cần human approval có thể gửi iframe form. A2A thiết kế Parts để cover tất cả những kịch bản này ngay từ đầu.

5.3. Artifacts - Output có cấu trúc

Artifacts là kết quả mà remote agent tạo ra, khác với messages ở chỗ artifacts đại diện cho deliverables cuối cùng thay vì hội thoại qua lại. Một task có thể tạo nhiều artifacts.

6. JSON-RPC Methods - API cốt lõi

A2A định nghĩa 11 JSON-RPC methods chia thành 4 nhóm chức năng:

6.1. Task Management

// SendMessage - Gửi message và tạo/tiếp tục task
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "SendMessage",
  "params": {
    "message": {
      "role": "user",
      "parts": [{ "text": "Tìm tất cả TODO comments trong repo" }]
    },
    "configuration": {
      "acceptedOutputModes": ["text", "file"],
      "historyLength": 10,
      "returnImmediately": false
    }
  }
}

// Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "id": "task-001",
    "contextId": "ctx-abc",
    "status": { "state": "COMPLETED" },
    "artifacts": [
      {
        "parts": [
          { "text": "Tìm thấy 23 TODO comments trong 8 files..." },
          { "structuredData": { "totalCount": 23, "files": ["main.py", "utils.py"] } }
        ]
      }
    ]
  }
}

6.2. Danh sách đầy đủ các methods

MethodNhómMô tả
SendMessageCoreGửi message, tạo hoặc tiếp tục task
SendStreamingMessageCoreGửi message với SSE streaming response
GetTaskQueryLấy trạng thái hiện tại của task
ListTasksQueryLiệt kê tasks với filter và pagination
CancelTaskControlHủy task đang chạy
SubscribeToTaskStreamingSubscribe SSE stream cho task updates
CreateTaskPushNotificationConfigPushCấu hình webhook push notification
GetTaskPushNotificationConfigPushLấy cấu hình push notification
ListTaskPushNotificationConfigsPushLiệt kê push notification configs
DeleteTaskPushNotificationConfigPushXóa push notification config
GetExtendedAgentCardDiscoveryLấy extended agent card (sau auth)

7. Streaming và Push Notifications

A2A hỗ trợ ba mô hình giao tiếp để cover mọi kịch bản từ tác vụ nhanh đến tác vụ kéo dài hàng giờ:

sequenceDiagram
    participant C as Client Agent
    participant R as Remote Agent

    Note over C,R: Pattern 1 - Synchronous
    C->>R: SendMessage
    R-->>C: Task COMPLETED with artifacts

    Note over C,R: Pattern 2 - SSE Streaming
    C->>R: SendStreamingMessage
    R-->>C: SSE TaskStatusUpdateEvent WORKING
    R-->>C: SSE TaskArtifactUpdateEvent partial
    R-->>C: SSE TaskStatusUpdateEvent COMPLETED

    Note over C,R: Pattern 3 - Push Notification
    C->>R: SendMessage returnImmediately true
    R-->>C: Task WORKING acknowledged
    Note over R: Long processing...
    R->>C: Webhook POST TaskStatusUpdateEvent COMPLETED

Hình 3: Ba mô hình giao tiếp - Synchronous, SSE Streaming, và Push Notification

7.1. SSE Streaming Events

Khi dùng SendStreamingMessage, remote agent trả về Server-Sent Events stream với hai loại event:

// TaskStatusUpdateEvent
{
  "taskId": "task-001",
  "newStatus": {
    "state": "WORKING",
    "message": { "role": "agent", "parts": [{ "text": "Đang scan repository..." }] }
  },
  "timestamp": "2026-04-13T10:30:05Z"
}

// TaskArtifactUpdateEvent
{
  "taskId": "task-001",
  "artifact": {
    "parts": [{ "text": "Phân tích hoàn tất: 5 critical issues found" }]
  },
  "timestamp": "2026-04-13T10:30:12Z"
}

7.2. Push Notifications cho Long-running Tasks

Khi task cần xử lý hàng giờ (ví dụ: train model, chạy test suite lớn), client đăng ký webhook và remote agent gửi notification khi có update. Push notifications luôn dùng HTTP bất kể agent dùng binding nào (gRPC hay JSON-RPC).

Lưu ý khi dùng Push Notifications

Push notification endpoint phải publicly accessible và hỗ trợ HTTPS. Trong enterprise environment, cần cấu hình firewall rules phù hợp. Nếu client agent chạy behind NAT, hãy dùng SSE streaming thay thế.

8. A2A + MCP: Bộ đôi hoàn hảo cho Multi-Agent Systems

Đây là phần quan trọng nhất: hiểu rõ khi nào dùng gìcách phối hợp hai giao thức.

Tiêu chíMCP (Anthropic)A2A (Google)
Vai tròAgent kết nối Tool/DataAgent giao tiếp với Agent
Ví vonUSB-C (cắm thiết bị ngoại vi)HTTP (máy chủ nói chuyện với nhau)
Trục giao tiếpDọc (vertical)Ngang (horizontal)
DiscoveryServer Cards + MCP RegistryAgent Cards tại /.well-known/agent.json
Transportstdio, Streamable HTTPHTTP, SSE, gRPC
Unit of WorkTool call (đơn lẻ, nhanh)Task (có thể kéo dài, multi-step)
State ModelStateful sessionTask-based state machine (7 states)
TransparencyClient thấy tool definitionsAgent là opaque black box
FoundationAAIF - Linux FoundationAAIF - Linux Foundation
graph TD
    A["Orchestrator Agent"] -->|"A2A"| B["Code Review Agent"]
    A -->|"A2A"| C["Testing Agent"]
    A -->|"A2A"| D["Deploy Agent"]
    A -->|"MCP"| E["Jira Server"]
    B -->|"MCP"| F["GitHub Server"]
    B -->|"MCP"| G["Linter Tools"]
    C -->|"MCP"| H["Test Runner"]
    C -->|"MCP"| I["Database"]
    D -->|"MCP"| J["K8s Server"]
    D -->|"MCP"| K["AWS Server"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#4285f4,stroke:#fff,color:#fff
    style C fill:#4285f4,stroke:#fff,color:#fff
    style D fill:#4285f4,stroke:#fff,color:#fff
    style E fill:#4CAF50,stroke:#fff,color:#fff
    style F fill:#4CAF50,stroke:#fff,color:#fff
    style G fill:#4CAF50,stroke:#fff,color:#fff
    style H fill:#4CAF50,stroke:#fff,color:#fff
    style I fill:#4CAF50,stroke:#fff,color:#fff
    style J fill:#4CAF50,stroke:#fff,color:#fff
    style K fill:#4CAF50,stroke:#fff,color:#fff

Hình 4: Kiến trúc hybrid A2A + MCP - Orchestrator dùng A2A để phối hợp agents, mỗi agent dùng MCP để truy cập tools

Quy tắc vàng khi chọn giao thức

Dùng MCP khi entity bên kia là tool/service đơn giản (database, API, file system). Dùng A2A khi entity bên kia là agent thông minh có khả năng ra quyết định. Nếu bạn cần entity kia "suy nghĩ" và "lên kế hoạch" thay vì chỉ "thực thi lệnh" - đó là A2A.

9. Bảo mật và xác thực

A2A được thiết kế enterprise-grade từ đầu, hỗ trợ 5 cơ chế xác thực:

9.1. Security Schemes

SchemeMô tảKhi nào dùng
API KeyToken trong header/queryInternal services, development
HTTP AuthBasic hoặc Bearer tokenSimple integrations
OAuth 2.0Authorization Code, Client Credentials, Device CodeProduction, third-party agents
OpenID ConnectDelegated identity verificationEnterprise SSO integration
Mutual TLSCertificate-based two-way authHigh-security, zero-trust environments

9.2. Extended Agent Cards

Một pattern thông minh: Agent Card công khai chỉ chứa thông tin cơ bản. Sau khi client authenticate, có thể gọi GetExtendedAgentCard để lấy card đầy đủ với skills nhạy cảm chỉ available cho authorized clients.

// Public Agent Card - ai cũng thấy
{
  "name": "finance-agent",
  "skills": [{ "id": "market-summary", "name": "Market Summary" }],
  "capabilities": { "extendedAgentCard": true }
}

// Extended Agent Card - chỉ sau authentication
{
  "name": "finance-agent",
  "skills": [
    { "id": "market-summary", "name": "Market Summary" },
    { "id": "trade-execution", "name": "Execute Trade" },
    { "id": "portfolio-analysis", "name": "Portfolio Risk Analysis" }
  ]
}

10. Production Patterns cho A2A

Pattern 1: Hub-and-Spoke

Một orchestrator agent trung tâm phối hợp nhiều specialized agents. Phổ biến nhất trong enterprise.

graph TD
    A["Orchestrator"] -->|"A2A"| B["Research Agent"]
    A -->|"A2A"| C["Analysis Agent"]
    A -->|"A2A"| D["Report Agent"]
    B -->|"Findings"| A
    C -->|"Insights"| A
    A -->|"Combined context"| D
    D -->|"Final report"| A
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#4285f4,stroke:#fff,color:#fff
    style C fill:#ff9800,stroke:#fff,color:#fff
    style D fill:#4CAF50,stroke:#fff,color:#fff

Hình 5: Hub-and-Spoke Pattern - Orchestrator phối hợp các specialized agents

Pattern 2: Pipeline Chain

Agents xử lý tuần tự, output agent trước trở thành input agent sau. Phù hợp cho quy trình có các bước rõ ràng.

graph LR
    A["Data Collection Agent"] -->|"A2A"| B["Data Cleaning Agent"]
    B -->|"A2A"| C["Analysis Agent"]
    C -->|"A2A"| D["Visualization Agent"]
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#ff9800,stroke:#fff,color:#fff
    style C fill:#4285f4,stroke:#fff,color:#fff
    style D fill:#4CAF50,stroke:#fff,color:#fff

Hình 6: Pipeline Chain - Agents xử lý tuần tự theo chuỗi

Pattern 3: Peer-to-Peer Negotiation

Hai hoặc nhiều agents trao đổi trực tiếp để đàm phán, lên kế hoạch, hoặc giải quyết xung đột. Ví dụ: agent scheduling tìm thời gian họp bằng cách negotiate trực tiếp với calendar agents của mỗi người tham gia.

Pattern 4: Hierarchical Delegation

Agent nhận task có thể delegate sub-tasks cho agents khác qua A2A, tạo thành cây phân cấp. Manager agent chỉ cần biết khả năng của agent cấp dưới qua Agent Cards.

Anti-pattern cần tránh

Đừng dùng A2A khi MCP đã đủ. Nếu bạn chỉ cần query database hay gọi API, dùng MCP server. A2A chỉ cần khi bên kia thực sự là agent thông minh cần "suy nghĩ". Over-engineering với A2A cho simple tools sẽ tăng latency và complexity không cần thiết.

11. Triển khai A2A Agent với Python

Dưới đây là ví dụ xây dựng một A2A remote agent đơn giản sử dụng Python SDK chính thức:

from a2a.server import A2AServer, AgentCard, Skill
from a2a.types import (
    Task, Message, Part, TextPart,
    TaskStatus, TaskState
)

# Định nghĩa Agent Card
agent_card = AgentCard(
    name="code-analyzer",
    description="Phân tích code quality và security vulnerabilities",
    version="1.0.0",
    capabilities={
        "streaming": True,
        "pushNotifications": False,
    },
    skills=[
        Skill(
            id="analyze-code",
            name="Analyze Code",
            description="Phân tích code và trả về báo cáo chi tiết",
            input_schema={
                "type": "object",
                "properties": {
                    "code": {"type": "string"},
                    "language": {"type": "string"}
                },
                "required": ["code", "language"]
            }
        )
    ],
    security_schemes={
        "bearer": {"type": "http", "scheme": "bearer"}
    },
    security=[["bearer"]]
)

server = A2AServer(agent_card=agent_card)

@server.on_message
async def handle_message(message: Message, task: Task) -> Task:
    """Xử lý message từ client agent"""

    # Cập nhật status: đang xử lý
    task.status = TaskStatus(state=TaskState.WORKING)
    await task.send_status_update("Đang phân tích code...")

    # Trích xuất code từ message parts
    code_content = ""
    for part in message.parts:
        if isinstance(part, TextPart):
            code_content = part.text

    # Phân tích code (simplified)
    analysis_result = await analyze_code(code_content)

    # Trả về artifact
    task.artifacts.append({
        "parts": [
            {"text": analysis_result["summary"]},
            {"structuredData": analysis_result["details"]}
        ]
    })

    task.status = TaskStatus(state=TaskState.COMPLETED)
    return task

# Chạy server
server.run(host="0.0.0.0", port=8080)

11.1. Client Agent gọi Remote Agent

from a2a.client import A2AClient

# Discover agent qua Agent Card
client = A2AClient("https://code-analyzer.example.com")
card = await client.get_agent_card()
print(f"Agent: {card.name}, Skills: {[s.name for s in card.skills]}")

# Gửi message và nhận kết quả
task = await client.send_message(
    message=Message(
        role="user",
        parts=[TextPart(text="def get_user(id): return db.query(f'SELECT * FROM users WHERE id={id}')")]
    ),
    configuration={
        "acceptedOutputModes": ["text", "structuredData"],
        "historyLength": 5
    }
)

print(f"Task status: {task.status.state}")
for artifact in task.artifacts:
    for part in artifact.parts:
        print(part)

12. gRPC Binding - Hiệu năng cao cho Internal Services

Từ v0.3, A2A hỗ trợ gRPC binding bên cạnh HTTP/JSON-RPC. gRPC phù hợp cho communication giữa internal agents trong cùng cluster/VPC nhờ hiệu năng cao hơn.

Tiêu chíHTTP/JSON-RPCgRPC
FormatJSON (human-readable)Protobuf (binary, compact)
PerformanceTốt cho external communicationNhanh hơn 2-5x cho internal
StreamingSSE (server-to-client)Bidirectional streaming
Use CaseCross-org, public agentsInternal microservices, same cluster
Toolingcurl, Postman, browsergrpcurl, dedicated clients

Khi nào dùng gRPC?

Dùng gRPC cho A2A communication giữa các agents internal trong cùng infrastructure - latency thấp hơn đáng kể. Giữ HTTP/JSON-RPC cho cross-organization agents hoặc khi cần debug dễ dàng. Một agent có thể expose cả hai interfaces cùng lúc.

13. Hệ sinh thái và tương lai

13.1. Tích hợp với các AI Frameworks

A2A đã được tích hợp vào các framework phổ biến:

  • Google Vertex AI Agent Engine: Hỗ trợ A2A native, deploy agent trực tiếp lên Vertex
  • LangGraph: A2A adapter cho LangGraph agents, kết nối với bất kỳ A2A agent nào
  • CrewAI: Plugin A2A cho inter-crew communication
  • Claude Code: Sub-agents có thể giao tiếp qua A2A trong tương lai

13.2. AAIF - Tương lai hội tụ MCP + A2A

Với cả MCP và A2A cùng thuộc Agentic AI Foundation (AAIF), roadmap hội tụ đã rõ ràng:

graph TD
    A["AAIF - Linux Foundation"] --> B["MCP Standard"]
    A --> C["A2A Standard"]
    A --> D["Shared Specs"]
    D --> E["Common Auth Model"]
    D --> F["Unified Discovery"]
    D --> G["Interop Testing"]
    B --> H["Agent to Tool"]
    C --> I["Agent to Agent"]
    H --> J["Complete Agentic Stack"]
    I --> J
    style A fill:#e94560,stroke:#fff,color:#fff
    style B fill:#0f3460,stroke:#fff,color:#fff
    style C fill:#4285f4,stroke:#fff,color:#fff
    style J fill:#4CAF50,stroke:#fff,color:#fff

Hình 7: Roadmap AAIF - MCP và A2A hội tụ thành Agentic Stack hoàn chỉnh

13.3. Xu hướng 2026-2027

  • Agent Marketplaces: Nền tảng publish/discover A2A agents tương tự MCP Registry
  • Multi-modal Agents: Agents giao tiếp qua video/audio streaming, không chỉ text
  • Agent Identity & Reputation: Hệ thống đánh giá độ tin cậy của agents dựa trên lịch sử
  • Autonomous Agent Networks: Mạng lưới agents tự động discover, negotiate và phối hợp mà không cần human orchestration

14. Kết luận

A2A Protocol đánh dấu bước chuyển quan trọng: từ "AI agents hoạt động đơn lẻ" sang "AI agents phối hợp như một đội ngũ". Cùng với MCP tạo thành bộ đôi giao thức nền tảng cho kỷ nguyên Agentic AI.

Những điểm then chốt cần nhớ:

  • A2A cho agent-to-agent, MCP cho agent-to-tool - hai giao thức bổ trợ, không cạnh tranh
  • Agent Cards là trung tâm - thiết kế Agent Card tốt là bước quan trọng nhất khi triển khai
  • Bắt đầu đơn giản - dùng single agent + MCP trước, chỉ thêm A2A khi thực sự cần agent phối hợp
  • Security first - luôn cấu hình authentication, dùng Signed Agent Cards trong production
  • Chọn transport phù hợp - HTTP cho external, gRPC cho internal, SSE cho streaming

Thế giới AI đang chuyển từ "mô hình đơn lẻ thông minh hơn" sang "hệ thống đa agent phối hợp tốt hơn". A2A chính là giao thức phối hợp đó - và với sự hậu thuẫn của AAIF cùng 150+ tổ chức, đây không còn là thí nghiệm mà là chuẩn công nghiệp đang hình thành.

Bắt đầu ngay hôm nay

1. Đọc A2A spec chính thức tại a2a-protocol.org. 2. Thử deploy một A2A agent đơn giản bằng Python SDK. 3. Kết hợp với MCP servers đã có. 4. Tham gia AAIF community trên GitHub để theo dõi roadmap.