版本: 0.1.0
Agent2Agent (A2A) 协议是一个开放标准,旨在促进独立、可能不透明的AI代理系统之间的通信和互操作性。在一个代理可能使用不同框架、语言或由不同供应商构建的生态系统中,A2A提供了通用语言和交互模型。
本文档提供了A2A协议的详细技术规范。其主要目标是使代理能够:
有关A2A目的和好处的更广泛理解,请参见什么是A2A?
A2A围绕几个关键概念展开。详细解释请参考关键概念指南
role
("user"或"agent")并包含一个或多个Parts
TextPart
、FilePart
、DataPart
)Parts
组成AgentCard
中定义的URL公开其服务A2A使用**JSON-RPC 2.0**作为所有请求和响应的有效载荷格式(不包括SSE流包装器)
Content-Type
头必须为application/json
当对tasks/sendSubscribe
或tasks/resubscribe
等方法使用流式传输时:
200 OK
状态和Content-Type
头为text/event-stream
data
字段包含一个完整的JSON-RPC 2.0响应对象(具体来说是SendTaskStreamingResponse
)A2A将代理视为标准企业应用程序,依赖于已建立的Web安全实践。身份信息不会在A2A JSON-RPC有效载荷中传输;它在HTTP传输层处理。
有关企业安全方面的全面指南,请参见企业就绪功能
如第3.1节所述,生产部署必须使用HTTPS。实现应该使用现代TLS配置(推荐TLS 1.2+)和强密码套件
A2A客户端应该通过在TLS握手期间根据受信任的证书颁发机构(CA)验证A2A服务器的TLS证书来验证其身份
AgentCard
中的authentication
字段发现服务器所需的认证方案。方案名称通常与OpenAPI认证方法对齐(例如,"Bearer"用于OAuth 2.0令牌,"Basic"用于基本认证,"ApiKey"用于API密钥)Authorization: Bearer <token>
、X-API-Key: <value>
)A2A服务器:
401 Unauthorized
或403 Forbidden
进行认证挑战或拒绝401 Unauthorized
响应中包含相关HTTP头(例如WWW-Authenticate
)以指示所需的认证方案,指导客户端如果代理在执行任务期间需要_额外_凭证用于_不同_系统或资源(例如代表用户访问需要自己认证的特定工具):
input-required
状态(参见TaskState
)TaskStatus.message
(通常是DataPart
)应该提供关于所需二次认证的详细信息,可能使用类似AuthenticationInfo
的结构来描述需求tasks/send
或tasks/sendSubscribe
请求中提供它们。这些凭证的使用方式(例如如果代理正在代理,则在A2A消息中作为数据传递,或由客户端直接与辅助系统交互使用)取决于特定场景一旦客户端被认证,A2A服务器负责基于认证的客户端/用户身份及其自身策略授权请求。授权逻辑是特定于实现的,可以基于以下内容强制执行:
AgentSkill.id
)服务器应实施最小权限原则
A2A服务器必须提供代理卡。代理卡是一个JSON文档,描述服务器的身份、能力、技能、服务端点URL以及客户端应如何认证和与其交互。客户端使用此信息发现合适的代理并配置其交互
有关发现策略的更多信息,请参见代理发现指南
客户端可以通过各种方法找到代理卡,包括但不限于:
如果使用知名URI策略,代理卡的推荐位置是:
https://{server_domain}/.well-known/agent.json
这遵循RFC 8615对知名URI的原则
代理卡本身可能包含被视为敏感的信息(例如仅内部代理的URL,或authentication.credentials
中的方案特定信息)
authentication.credentials
,它应该用于非秘密信息,如OAuth流URL或API密钥_名称_(不是值)AgentCard
对象结构字段名 | 类型 | 必填 | 描述 |
---|---|---|---|
name |
string |
是 | 代理的人类可读名称 |
description |
string | null |
否 | 人类可读描述。可以使用CommonMark |
url |
string |
是 | 代理A2A服务的基本URL。必须是绝对URL。生产环境使用HTTPS |
provider |
AgentProvider | null |
否 | 关于代理提供者的信息 |
version |
string |
是 | 代理或A2A实现的版本字符串 |
documentationUrl |
string | null |
否 | 指向代理文档的URL |
capabilities |
AgentCapabilities |
是 | 指定支持的A2A协议可选功能(例如流式传输、推送通知) |
authentication |
AgentAuthentication | null |
否 | 所需的认证方案。null 或空表示没有A2A级认证广告(生产环境不建议) |
defaultInputModes |
string[] |
否 | 默认接受的输入MIME类型。省略时默认为["text/plain"] |
defaultOutputModes |
string[] |
否 | 默认产生的输出MIME类型。省略时默认为["text/plain"] |
skills |
AgentSkill[] |
是 | 技能数组。如果代理执行操作则必须至少有一个 |
AgentProvider
对象关于提供代理的组织或实体的信息
字段名 | 类型 | 必填 | 描述 |
---|---|---|---|
organization |
string |
是 | 组织/实体的名称 |
url |
string | null |
否 | 提供者网站/联系页面的URL |
AgentCapabilities
对象指定代理支持的A2A协议可选功能
字段名 | 类型 | 必填 | 默认 | 描述 |
---|---|---|---|---|
streaming |
boolean |
否 | false |
表示支持SSE流式方法(tasks/sendSubscribe 、tasks/resubscribe ) |
pushNotifications |
boolean |
否 | false |
表示支持推送通知方法(tasks/pushNotification/* ) |
stateTransitionHistory |
boolean |
否 | false |
未来功能的占位符:公开详细的任务状态更改历史 |
AgentAuthentication
对象描述访问代理url
端点所需的认证要求
字段名 | 类型 | 必填 | 描述 |
---|---|---|---|
schemes |
string[] |
是 | 认证方案名称数组(例如"Bearer"、"OAuth2"、"ApiKey") |
credentials |
string | null |
否 | 非秘密的方案特定信息。不得包含明文秘密。如果包含敏感信息,代理卡端点必须受到保护 |
AgentSkill
ObjectDescribes a specific capability, function, or area of expertise the agent can perform or address.
Field Name | Type | Required | Description |
---|---|---|---|
id |
string |
Yes | Unique skill identifier within this agent. |
name |
string |
Yes | Human-readable skill name. |
description |
string | null |
No | Detailed skill description. CommonMark MAY be used. |
tags |
string[] | null |
No | Keywords/categories for discoverability. |
examples |
string[] | null |
No | Example prompts or use cases demonstrating skill usage. |
inputModes |
string[] | null |
No | Overrides defaultInputModes for this specific skill. Accepted MIME types. |
outputModes |
string[] | null |
No | Overrides defaultOutputModes for this specific skill. Produced MIME types. |
These objects define the structure of data exchanged within the JSON-RPC methods of the A2A protocol.
Task
ObjectRepresents the stateful unit of work being processed by the A2A Server for an A2A Client. A task encapsulates the entire interaction related to a specific goal or request.
Field Name | Type | Required | Description |
---|---|---|---|
id |
string |
Yes | Unique task identifier (e.g., UUID), typically client-generated. |
sessionId |
string | null |
No | Optional client-generated ID to group related tasks into a session. |
status |
TaskStatus |
Yes | Current status of the task (state, message, timestamp). |
artifacts |
Artifact[] | null |
No | Array of outputs generated by the agent for this task. |
history |
Message[] | null |
No | Optional array of recent messages exchanged, if requested by historyLength . |
metadata |
Record<string, any> | null |
No | Arbitrary key-value metadata associated with the task. |
TaskStatus
ObjectRepresents the current state and associated context (e.g., a message from the agent) of a Task
.
Field Name | Type | Required | Description |
---|---|---|---|
state |
TaskState |
Yes | Current lifecycle state of the task. |
message |
Message | null |
No | Optional message providing context for the current status. |
timestamp |
string (ISO 8601) | null |
No | Timestamp (UTC recommended) when this status was recorded. |
TaskState
EnumDefines the possible lifecycle states of a Task
.
Value | Description | Terminal? |
---|---|---|
submitted |
Task received by the server and acknowledged, but processing has not yet actively started. | No |
working |
Task is actively being processed by the agent. Client may expect further updates or a terminal state. | No |
input-required |
Agent requires additional input from the client/user to proceed. The task is effectively paused. | No (Pause) |
completed |
Task finished successfully. Results are typically available in Task.artifacts or TaskStatus.message . |
Yes |
canceled |
Task was canceled (e.g., by a tasks/cancel request or server-side policy). |
Yes |
failed |
Task terminated due to an error during processing. TaskStatus.message may contain error details. |
Yes |
unknown |
The state of the task cannot be determined (e.g., task ID is invalid, unknown, or has expired). | Yes |
Message
ObjectRepresents a single communication turn or a piece of contextual information within a Task
. Messages are used for instructions, prompts, replies, and status updates.
Field Name | Type | Required | Description |
---|---|---|---|
role |
"user" | "agent" |
Yes | Indicates the sender: "user" (from A2A Client) or "agent" (from A2A Server). |
parts |
Part[] |
Yes | Array of content parts. Must contain at least one part. |
metadata |
Record<string, any> | null |
No | Arbitrary key-value metadata associated with this message. |
Part
Union TypeRepresents a distinct piece of content within a Message
or Artifact
. A Part
object is a discriminated union, identified by its mandatory type
field. All Part
types also include an optional metadata
field (Record<string, any> | null
) for part-specific metadata.
It MUST be one of the following:
TextPart
ObjectFor conveying plain textual content.
Field Name | Type | Required | Description |
---|---|---|---|
type |
"text" (literal) |
Yes | Identifies this part as textual content. |
text |
string |
Yes | The textual content of the part. |
metadata |
Record<string, any> | null |
No | Optional metadata specific to this text part. |
FilePart
ObjectFor conveying file-based content.
Field Name | Type | Required | Description |
---|---|---|---|
type |
"file" (literal) |
Yes | Identifies this part as file content. |
file |
FileContent |
Yes | Contains the file details and data/reference. |
metadata |
Record<string, any> | null |
No | Optional metadata specific to this file part. |
DataPart
ObjectFor conveying structured JSON data. Useful for forms, parameters, or any machine-readable information.
Field Name | Type | Required | Description |
---|---|---|---|
type |
"data" (literal) |
Yes | Identifies this part as structured data. |
data |
Record<string, any> | any[] |
Yes | The structured JSON data payload (an object or an array). |
metadata |
Record<string, any> | null |
No | Optional metadata specific to this data part (e.g., reference to a schema). |
FileContent
ObjectRepresents the data or reference for a file, used within a FilePart
.
Field Name | Type | Required | Description |
---|---|---|---|
name |
string | null |
No | Original filename (e.g., "report.pdf"). |
mimeType |
string | null |
No | MIME type (e.g., image/png ). Strongly recommended. |
bytes |
string | null |
Conditionally (See Constraint) | Base64 encoded file content. |
uri |
string | null |
Conditionally (See Constraint) | URI (absolute URL strongly recommended) to file content. Accessibility is context-dependent. |
Constraint: If file content is being transmitted, exactly one of bytes
or uri
MUST be provided and non-null. Both MAY be null
or absent if the FilePart
is only a reference or metadata about a file whose content is not being transferred in this specific part.
Artifact
ObjectRepresents a tangible output generated by the agent during a task. Artifacts are the results or products of the agent's work.
Field Name | Type | Required | Default | Description |
---|---|---|---|---|
name |
string | null |
No | null |
Descriptive name for the artifact. |
description |
string | null |
No | null |
Human-readable description of the artifact. |
parts |
Part[] |
Yes | Content of the artifact, as one or more Part objects. Must have at least one. |
|
index |
integer |
No | 0 |
Non-negative index for ordering artifacts or identifying chunks during streaming. |
append |
boolean | null |
No | false |
In streaming (TaskArtifactUpdateEvent ), true means append parts to artifact at index ; false (default) means replace. |
lastChunk |
boolean | null |
No | false |
In streaming (TaskArtifactUpdateEvent ), true indicates this is the final update for the artifact at this index . |
metadata |
Record<string, any> | null |
No | null |
Arbitrary key-value metadata associated with the artifact. |
PushNotificationConfig
ObjectConfiguration provided by the client to the server for sending asynchronous push notifications about task updates.
Field Name | Type | Required | Description |
---|---|---|---|
url |
string |
Yes | Absolute HTTPS webhook URL for the A2A Server to POST task updates to. |
token |
string | null |
No | Optional client-generated opaque token for the client's webhook receiver to validate the notification (e.g., server includes it in an X-A2A-Notification-Token header). |
authentication |
AuthenticationInfo | null |
No | Authentication details the A2A Server must use when calling the url . The client's webhook (receiver) defines these requirements. |
AuthenticationInfo
Object (for Push Notifications)A generic structure for specifying authentication requirements, typically used within PushNotificationConfig
to describe how the A2A Server should authenticate to the client's webhook.
Field Name | Type | Required | Description |
---|---|---|---|
schemes |
string[] |
Yes | Array of auth scheme names the A2A Server must use when calling the client's webhook (e.g., "Bearer", "ApiKey"). |
credentials |
string | null |
No | Optional static credentials or scheme-specific configuration info. Handle with EXTREME CAUTION if secrets are involved. Prefer server-side dynamic credential fetching where possible. |
TaskPushNotificationConfig
ObjectUsed as the params
object for the tasks/pushNotification/set
method and as the result
object for the tasks/pushNotification/get
method.
Field Name | Type | Required | Description |
---|---|---|---|
id |
string |
Yes | The ID of the task to configure push notifications for, or retrieve configuration from. |
pushNotificationConfig |
PushNotificationConfig | null |
Yes | The push notification configuration. For set , the desired config. For get , the current config (secrets MAY be omitted by server). null might clear config on set . |
A2A adheres to the standard JSON-RPC 2.0 structures for requests and responses.
JSONRPCRequest
ObjectAll A2A method calls are encapsulated in a JSON-RPC Request object.
jsonrpc
: A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0"
.method
: A String containing the name of the method to be invoked (e.g., "tasks/send"
, "tasks/get"
).params
: A Structured value that holds the parameter values to be used during the invocation of the method. This member MAY be omitted if the method expects no parameters. A2A methods typically use an object
for params
.id
: An identifier established by the Client that MUST contain a String, Number, or NULL
value if included. If it is not included it is assumed to be a notification. The value SHOULD NOT be NULL
for requests expecting a response, and Numbers SHOULD NOT contain fractional parts. The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects. A2A methods typically expect a response or stream, so id
will usually be present and non-null.JSONRPCResponse
ObjectResponses from the A2A Server are encapsulated in a JSON-RPC Response object.
jsonrpc
: A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0"
.id
: This member is REQUIRED. It MUST be the same as the value of the id
member in the Request Object. If there was an error in detecting the id
in the Request object (e.g. Parse error/Invalid Request), it MUST be null
.result
: This member is REQUIRED on success. This member MUST NOT exist if there was an error invoking the method. The value of this member is determined by the method invoked on the Server.error
: This member is REQUIRED on failure. This member MUST NOT exist if there was no error triggered during invocation. The value of this member MUST be an JSONRPCError
object.result
and error
are mutually exclusive: one MUST be present, and the other MUST NOT.JSONRPCError
ObjectWhen a JSON-RPC call encounters an error, the Response Object will contain an error
member with a value of this structure.
Field Name | Type | Required | Description |
---|---|---|---|
code |
integer |
Yes | Integer error code. See Section 8 (Error Handling) for standard and A2A-specific codes. |
message |
string |
Yes | Short, human-readable summary of the error. |
data |
any | null |
No | Optional additional structured information about the error. |
All A2A RPC methods are invoked by the A2A Client by sending an HTTP POST request to the A2A Server's url
(as specified in its AgentCard
). The body of the HTTP POST request MUST be a JSONRPCRequest
object, and the Content-Type
header MUST be application/json
.
The A2A Server's HTTP response body MUST be a JSONRPCResponse
object (or, for streaming methods, an SSE stream where each event's data is a JSONRPCResponse
). The Content-Type
for JSON-RPC responses is application/json
. For SSE streams, it is text/event-stream
.
tasks/send
Sends a message to an agent to initiate a new task or to continue an existing one. This method is suitable for synchronous request/response interactions or when client-side polling (using tasks/get
) is acceptable for monitoring longer-running tasks.
params
type: TaskSendParams
result
type (on success): Task
(The current or final state of the task after processing the message).error
type (on failure): JSONRPCError
.TaskSendParams
ObjectField Name | Type | Required | Description |
---|---|---|---|
id |
string |
Yes | Task ID. If new, the server SHOULD create the task. If existing, this message continues the task. |
sessionId |
string | null |
No | Optional client-generated session ID. |
message |
Message |
Yes | The message content to send. Message.role is typically "user" . |
pushNotification |
PushNotificationConfig | null |
No | Optional: sets push notification configuration for the task (usually on the first send). Requires server capability. |
historyLength |
integer | null |
No | If positive, requests the server to include up to N recent messages in Task.history . |
metadata |
Record<string, any> | null |
No | Request-specific metadata. |
tasks/sendSubscribe
Sends a message to an agent to initiate/continue a task AND subscribes the client to real-time updates for that task via Server-Sent Events (SSE). This method requires the server to have AgentCard.capabilities.streaming: true
.
params
type: TaskSendParams
(same as tasks/send
).200 OK
.Content-Type
: text/event-stream
.data
field contains a SendTaskStreamingResponse
JSON object.JSONRPCResponse
with an error
object detailing the failure.SendTaskStreamingResponse
ObjectThis is the structure of the JSON object found in the data
field of each Server-Sent Event sent by the server for a tasks/sendSubscribe
or tasks/resubscribe
stream. It's a JSONRPCResponse
where the result
is one of the event types.
Field Name | Type | Required | Description |
---|---|---|---|
jsonrpc |
"2.0" (literal) |
Yes | JSON-RPC version string. |
id |
string | number |
Yes | Matches the id from the originating tasks/sendSubscribe or tasks/resubscribe request. |
result |
Either TaskStatusUpdateEvent OR TaskArtifactUpdateEvent |
Yes | The event payload: either a status update or an artifact update. |
error |
JSONRPCError | null |
No | Typically null or absent for stream events. If a fatal stream error occurs, this MAY be populated in the final SSE message before the stream closes. |
TaskStatusUpdateEvent
ObjectCarries information about a change in the task's status during streaming. This is one of the possible result
types in a SendTaskStreamingResponse
.
Field Name | Type | Required | Default | Description |
---|---|---|---|---|
id |
string |
Yes | Task ID being updated, matching the original request's task ID. | |
status |
TaskStatus |
Yes | The new TaskStatus object. |
|
final |
boolean |
No | false |
If true , indicates this is the terminal status update for the current stream cycle. The server typically closes the SSE connection after this. |
metadata |
Record<string, any> | null |
No | null |
Event-specific metadata. |
TaskArtifactUpdateEvent
ObjectCarries a new or updated artifact (or a chunk of an artifact) generated by the task during streaming. This is one of the possible result
types in a SendTaskStreamingResponse
.
Field Name | Type | Required | Default | Description |
---|---|---|---|---|
id |
string |
Yes | Task ID that generated the artifact, matching the original request's task ID. | |
artifact |
Artifact |
Yes | The Artifact data. Could be a complete artifact or an incremental chunk. Use index , append , and lastChunk fields within Artifact for client-side assembly. |
|
metadata |
Record<string, any> | null |
No | null |
Event-specific metadata. |
tasks/get
Retrieves the current state (including status, artifacts, and optionally history) of a previously initiated task. This is typically used for polling the status of a task initiated with tasks/send
, or for fetching the final state of a task after being notified via a push notification or after an SSE stream has ended.
params
type: TaskQueryParams
result
type (on success): Task
(A snapshot of the task's current state).error
type (on failure): JSONRPCError
(e.g., if the task ID is not found, see TaskNotFoundError
).TaskQueryParams
ObjectField Name | Type | Required | Description |
---|---|---|---|
id |
string |
Yes | The ID of the task whose current state is to be retrieved. |
historyLength |
integer | null |
No | If positive, requests the server to include up to N recent messages in Task.history . |
metadata |
Record<string, any> | null |
No | Request-specific metadata. |
tasks/cancel
Requests the cancellation of an ongoing task. The server will attempt to cancel the task, but success is not guaranteed (e.g., the task might have already completed or failed, or cancellation might not be supported at its current stage).
params
type: TaskIdParams
result
type (on success): Task
(The state of the task after the cancellation attempt. Ideally, Task.status.state
will be "canceled"
if successful).error
type (on failure): JSONRPCError
(e.g., TaskNotFoundError
, TaskNotCancelableError
).TaskIdParams
Object (for tasks/cancel
and tasks/pushNotification/get
)A simple object containing just the task ID and optional metadata.
Field Name | Type | Required | Description |
---|---|---|---|
id |
string |
Yes | The ID of the task. |
metadata |
Record<string, any> | null |
No | Request-specific metadata. |
tasks/pushNotification/set
Sets or updates the push notification configuration for a specified task. This allows the client to tell the server where and how to send asynchronous updates for the task. Requires the server to have AgentCard.capabilities.pushNotifications: true
.
params
type: TaskPushNotificationConfig
result
type (on success): TaskPushNotificationConfig
(Confirms the configuration that was set. The server MAY omit or mask any sensitive details like secrets from the authentication.credentials
field in the response).error
type (on failure): JSONRPCError
(e.g., PushNotificationNotSupportedError
, TaskNotFoundError
, errors related to invalid PushNotificationConfig
).tasks/pushNotification/get
Retrieves the current push notification configuration for a specified task. Requires the server to have AgentCard.capabilities.pushNotifications: true
.
params
type: TaskIdParams
result
type (on success): TaskPushNotificationConfig
(The current push notification configuration for the task. If no configuration is set, pushNotificationConfig
field might be null
or an empty object. The server MAY omit or mask any sensitive details from the authentication.credentials
field).error
type (on failure): JSONRPCError
(e.g., PushNotificationNotSupportedError
, TaskNotFoundError
).tasks/resubscribe
Allows a client to reconnect to an SSE stream for an ongoing task after a previous connection (from tasks/sendSubscribe
or an earlier tasks/resubscribe
) was interrupted. Requires the server to have AgentCard.capabilities.streaming: true
.
The purpose is to resume receiving subsequent updates. The server's behavior regarding events missed during the disconnection period (e.g., whether it attempts to backfill some missed events or only sends new ones from the point of resubscription) is implementation-dependent and not strictly defined by this specification.
params
type: TaskQueryParams
(The historyLength
parameter is typically ignored for resubscription, as the focus is on future events, but it's included for structural consistency).200 OK
.Content-Type
: text/event-stream
.tasks/sendSubscribe
, carrying subsequent SendTaskStreamingResponse
events for the task.JSONRPCResponse
with an error
object. Failures can occur if the task is no longer active, doesn't exist, or streaming is not supported/enabled for it.A2A uses standard JSON-RPC 2.0 error codes and structure for reporting errors. Errors are returned in the error
member of the JSONRPCResponse
object. See JSONRPCError
Object definition.
These are standard codes defined by the JSON-RPC 2.0 specification.
Code | JSON-RPC Spec Meaning | Typical A2A message |
Description |
---|---|---|---|
-32700 |
Parse error | Invalid JSON payload | Server received JSON that was not well-formed. |
-32600 |
Invalid Request | Invalid JSON-RPC Request | The JSON payload was valid JSON, but not a valid JSON-RPC Request object. |
-32601 |
Method not found | Method not found | The requested A2A RPC method (e.g., "tasks/foo" ) does not exist or is not supported. |
-32602 |
Invalid params | Invalid method parameters | The params provided for the method are invalid (e.g., wrong type, missing required field). |
-32603 |
Internal error | Internal server error | An unexpected error occurred on the server during processing. |
-32000 to -32099 |
Server error | (Server-defined) | Reserved for implementation-defined server-errors. A2A-specific errors use this range. |
These are custom error codes defined within the JSON-RPC server error range (-32000
to -32099
) to provide more specific feedback about A2A-related issues. Servers SHOULD use these codes where applicable.
Code | Error Name (Conceptual) | Typical message string |
Description |
---|---|---|---|
-32001 |
TaskNotFoundError |
Task not found | The specified task id does not correspond to an existing or active task. It might be invalid, expired, or already completed and purged. |
-32002 |
TaskNotCancelableError |
Task cannot be canceled | An attempt was made to cancel a task that is not in a cancelable state (e.g., it has already reached a terminal state like completed , failed , or canceled ). |
-32003 |
PushNotificationNotSupportedError |
Push Notification is not supported | Client attempted to use push notification features (e.g., tasks/pushNotification/set ) but the server agent does not support them (i.e., AgentCard.capabilities.pushNotifications is false ). |
-32004 |
OperationNotSupportedError |
This operation is not supported | The requested operation or a specific aspect of it (perhaps implied by parameters) is not supported by this server agent implementation. Broader than just method not found. |
-32005 |
ContentTypeNotSupportedError |
Incompatible content types | A MIME type provided in the request's message.parts (or implied for an artifact) is not supported by the agent or the specific skill being invoked. |
-32006 |
StreamingNotSupportedError |
Streaming is not supported | Client attempted tasks/sendSubscribe or tasks/resubscribe but the server agent does not support streaming (i.e., AgentCard.capabilities.streaming is false ). |
-32007 |
AuthenticationRequiredError |
Authentication required | The request lacks necessary authentication credentials, or the provided credentials are invalid or insufficient. This often accompanies an HTTP 401 Unauthorized status. |
-32008 |
AuthorizationFailedError |
Authorization failed | The authenticated identity is not authorized to perform the requested action or access the specified resource (e.g., a specific task or skill). This often accompanies an HTTP 403 Forbidden status. |
-32009 |
InvalidTaskStateError |
Invalid task state for operation | The operation is not valid for the task's current TaskState (e.g., trying to send a message to a task that is already completed ). |
-32010 |
RateLimitExceededError |
Rate limit exceeded | The client has made too many requests in a given amount of time. |
-32011 |
ResourceUnavailableError |
A required resource is unavailable | The server cannot complete the request because a necessary downstream resource or service is temporarily or permanently unavailable. |
Servers MAY define additional error codes within the -32000
to -32099
range for more specific scenarios not covered above, but they SHOULD document these clearly. The data
field of the JSONRPCError
object can be used to provide more structured details for any error.
This section provides illustrative JSON examples of common A2A interactions. Timestamps, session IDs, and request/response IDs are for demonstration purposes. For brevity, some optional fields might be omitted if not central to the example.
Scenario: Client asks a simple question, and the agent responds quickly.
Client sends a message using tasks/send
:
Server processes the request and responds (task completes quickly):
If the task were longer-running, the server might initially respond with status.state: "working"
. The client would then periodically call tasks/get
with params: {"id": "task-abc-123"}
until the task reaches a terminal state.
Scenario: Client asks the agent to write a short story, and the agent streams the story incrementally.
Client sends a message and subscribes using tasks/sendSubscribe
:
Server responds with HTTP 200 OK, Content-Type: text/event-stream
, and starts sending SSE events:
Event 1: Task status update - working
Event 2: Artifact update - first chunk of the story
Event 3: Artifact update - second chunk (appended)
Event 4: Artifact update - final chunk
Event 5: Task status update - completed
(Server closes the SSE connection after the final:true
event).
(Note: SSE id
and event
fields are part of the SSE protocol itself, distinct from the JSON-RPC id
within the data
payload).
Scenario: Client wants to book a flight, and the agent needs more information.
Client tasks/send
(initial request):
Server responds, task state is input-required
:
Client tasks/send
(providing the requested input, using the same task ID):
Server processes the new input and responds (e.g., task completed or more input needed):
Scenario: Client requests a long-running report generation and wants to be notified via webhook when it's done.
Client tasks/send
with pushNotification
config:
Server acknowledges the task (e.g., status submitted
or working
):
(Later) A2A Server completes the task and POSTs a notification to https://client.example.com/webhook/a2a-notifications
:
Authorization: Bearer <server_jwt_for_webhook_audience>
(if server authenticates to webhook)Content-Type: application/json
X-A2A-Notification-Token: secure-client-token-for-task-aaa
taskId
and status
):Client's Webhook Service:
Authorization
header (if applicable).X-A2A-Notification-Token
.Client (optionally, upon receiving and validating the push notification) calls tasks/get
to retrieve full artifacts:
(Server responds with the full Task
object, including the generated report in Task.artifacts
).
Scenario: Client sends an image for analysis, and the agent returns a modified image.
Client tasks/send
with a FilePart
(uploading image bytes):
Server processes the image and responds with a FilePart
in an artifact (e.g., providing a URI to the modified image):
Scenario: Client asks for a list of open support tickets in a specific JSON format.
Client tasks/send
, Part.metadata
hints at desired output schema/MIME type:
(Note: A2A doesn't formally standardize schema negotiation in v0.1.0, but metadata
can be used for such hints by convention between client/server).
Server responds with a DataPart
containing the structured JSON data:
These examples illustrate the flexibility of A2A in handling various interaction patterns and data types. Implementers should refer to the detailed object definitions for all fields and constraints.
A2A and MCP are complementary protocols designed for different aspects of agentic systems:
How they work together: An A2A Client agent might request an A2A Server agent to perform a complex task. The Server agent, in turn, might use MCP to interact with several underlying tools, APIs, or data sources to gather information or perform actions necessary to fulfill the A2A task.
For a more detailed comparison, see the A2A and MCP guide.
Security is a paramount concern in A2A. Key considerations include:
Authorization
header with Bearer tokens, API keys).AgentCard
.Message
and Artifact
parts to prevent injection attacks or processing errors.Message
and Artifact
parts. Minimize sensitive data transfer.For a comprehensive discussion, refer to the Enterprise-Ready Features guide.