AgentSkillsCN

a2a

在实施代理间通信、任务委托以及多代理协作的 Agent-to-Agent(A2A)协议时使用。 适用场景:代理间通信、代理间的任务委托、代理卡发布、多代理协作。 切勿用于:工具集成(使用 MCP)、代理支付(使用 AP2 或 X402)、代理定义(使用 ADL)。

SKILL.md
--- frontmatter
name: a2a
description: |
    Use when implementing the Agent-to-Agent (A2A) protocol for inter-agent communication, task delegation, and multi-agent collaboration.
    USE FOR: agent-to-agent communication, task delegation between agents, Agent Card publishing, multi-agent collaboration
    DO NOT USE FOR: tool integration (use mcp), agent payments (use ap2 or x402), agent definition (use adl)
license: Apache-2.0
metadata:
  displayName: "A2A (Agent-to-Agent Protocol)"
  author: "Tyler-R-Kendrick"
compatibility: claude, copilot, cursor

A2A — Agent-to-Agent Protocol

Overview

A2A is an open protocol from Google that defines how AI agents communicate, delegate tasks, and collaborate with each other. While MCP focuses on tool integration, A2A addresses agent-to-agent interoperability.

Core Concepts

Agent Card

Every A2A agent publishes an Agent Card at /.well-known/agent.json describing its capabilities:

json
{
  "name": "Research Agent",
  "description": "Finds and summarizes information on any topic",
  "url": "https://research-agent.example.com",
  "capabilities": {
    "streaming": true,
    "pushNotifications": true
  },
  "skills": [
    {
      "id": "web-research",
      "name": "Web Research",
      "description": "Search and summarize web content"
    }
  ]
}

Task Lifecycle

A2A communication revolves around Tasks with a defined lifecycle:

code
submitted → working → [input-required] → completed / failed / canceled

Messages and Parts

Agents exchange Messages containing Parts (text, files, data):

json
{
  "role": "agent",
  "parts": [
    { "type": "text", "text": "Here is the research summary." },
    { "type": "file", "file": { "name": "report.pdf", "mimeType": "application/pdf", "bytes": "..." } }
  ]
}

Transport

A2A uses HTTP + JSON-RPC 2.0:

  • POST / — send JSON-RPC requests
  • SSE — streaming responses for long-running tasks
  • Push notifications — webhook callbacks for async completion

Key Methods

MethodDescription
tasks/sendSend a message to create or continue a task
tasks/sendSubscribeSend and subscribe to streaming updates
tasks/getGet current task state
tasks/cancelCancel an in-progress task
tasks/pushNotification/setRegister a webhook for task updates

Example Flow

code
Client                          Agent
  │                               │
  │── tasks/send ────────────────►│  Create task with user message
  │◄── status: working ──────────│  Agent begins processing
  │◄── status: completed ────────│  Agent returns result
  │                               │

Multi-Agent Collaboration

A client agent can delegate subtasks to specialist agents:

  1. Discover agents via their Agent Cards
  2. Send tasks to the most suitable agent
  3. Receive results and incorporate into the parent task
  4. Handle input-required status for interactive collaboration

A2A vs MCP

AspectA2AMCP
FocusAgent-to-agent communicationAgent-to-tool integration
DiscoveryAgent Cards (.well-known/agent.json)Server capabilities negotiation
TransportHTTP + JSON-RPC + SSEstdio, HTTP + SSE
InteractionTask-based (long-running)Request-response (tool calls)
ComplementaryDelegates to agentsCalls tools

Best Practices

  • Publish an Agent Card with accurate skill descriptions so other agents can discover and route tasks correctly.
  • Use streaming (tasks/sendSubscribe) for long-running tasks to provide progress updates.
  • Handle the input-required status to support interactive multi-turn workflows.
  • Combine A2A with MCP — use A2A for agent-to-agent delegation and MCP for tool integration within each agent.
  • Implement idempotency on task IDs so retries don't create duplicate work.