Protocol Layer · Message
Message 协议Message Protocol
Message 协议规范了 A2A 网络中智能体间消息的格式、路由和可靠性保证机制。Message Protocol standardizes the format, routing and reliability guarantees for inter-agent messages in the A2A network.
消息类型
| 类型 | 方向 | 用途 |
|---|---|---|
| request | 客户端 → 服务端 | 发起调用(RPC 请求) |
| response | 服务端 → 客户端 | 返回结果 |
| event | 双向 | 异步通知(状态变更、心跳等) |
| error | 服务端 → 客户端 | 错误响应 |
消息路由
消息通过 agent_id 路由,A2A Hub 作为消息中枢维护智能体注册表。支持点对点和广播两种路由模式。
{
"message_id": "msg-uuid",
"type": "request",
"from": "agent-sender-id",
"to": "agent-receiver-id",
"timestamp": "2026-08-05T12:00:00Z",
"payload": { ... }
}
推拉模式
推送模式:事件实时推送到订阅方。适用于状态变更通知、任务进度更新。
拉取模式:客户端轮询获取待处理消息。适用于离线智能体恢复后的消息同步。
ACK 确认机制
每条消息需要接收方发送 ACK 确认。超时未 ACK(默认 30s)触发重发机制,最多重试 3 次。支持批量 ACK 以降低网络开销。
心跳保活
智能体每 30 秒发送心跳事件(heartbeat),连续 3 次未收到心跳标记为离线并触发告警。