Cheat sheets

A2A Protocol

Cards, messages, tasks, states, the three bindings, errors and the 0.3 layer of A2A 1.0.1. Facts from the manual.

  • Concepts and terms
  • Tasks and commands
  • Annotated code
  • Diagrams
  • Comparisons
  • Defaults and numbers
  • Troubleshooting
  • Questions and tips

Source

Protocol architecture#

GETPOSTmethodroutetaskclientPlannerclient, reads cardsclientAgentCard/.well-known/agent-card.jsonprocessJSON-RPC/a2a/jsonrpcprocessHandlerchecks, thenexecutorprocessHTTP+JSON/a2a/reststoreTask storerecord of each taskGETPOSTmethodroutetaskclientPlannerclient, reads cardsclientAgentCard/.well-known/agent-card.jsonprocessJSON-RPC/a2a/jsonrpcprocessHandlerchecks, then executorprocessHTTP+JSON/a2a/reststoreTask storerecord of each task

Send and read a task#

TaskCode
Read the agent cardGET /.well-known/agent-card.json HTTP/1.1
Send one message"method": "SendMessage" posted to /a2a/jsonrpc
Send the versionA2A-Version: 1.0
Send and return at once"returnImmediately": true in configuration
Open a stream"method": "SendStreamingMessage"

Commands over HTTP+JSON#

CommandWhat it does
POST /a2a/rest/message:sendSends a message. The reply is a task or a message.
POST /a2a/rest/tasks/<task id>:cancelAsks the server to stop a task that is not terminal.
GET /.well-known/agent-card.jsonReads the agent card from the well-known path.
POST /a2a/rest/tasks/<task id>:cancelReturns a task error when the task is already terminal.

Settings and defaults#

SettingDefaultNote
returnImmediatelyfalseA send waits for a terminal or interrupted state
historyLengthunsetThe server decides how much history to return. 0 returns no history.
pageSize50The maximum in ListTasks is 100
includeArtifactsfalseArtifacts are left out of list results
A2A-Version1.0Required on every request, with no patch number

Compare the bindings#

FactorJSON-RPCHTTP+JSONgRPC
Operation named bymethod, such as SendMessageroute, such as POST /message:sendrpc SendMessage in A2AService
Where it is sentone URL, /a2a/jsonrpc in the kitone route per operationlf.a2a.v1.A2AService over HTTP/2 with TLS
Stream framea data: line with a full JSON-RPC responsea data: line with the StreamResponse alonea server-streaming rpc of StreamResponse
TaskNotFoundError-32001 with HTTP 200HTTP 404NOT_FOUND
Version headerA2A-Version headerA2A-Version headera2a-version metadata key

Task states#

Active
TASK_STATE_SUBMITTED and TASK_STATE_WORKING. The agent is still working.
Interrupted
TASK_STATE_INPUT_REQUIRED and TASK_STATE_AUTH_REQUIRED. The task waits for you.
Terminal
TASK_STATE_COMPLETED, TASK_STATE_FAILED, TASK_STATE_CANCELED, TASK_STATE_REJECTED. The task never changes again.
TASK_STATE_UNSPECIFIED
never sent by the kit. Treat it as an error.

Questions and answers#

Why does a send wait?
The default returnImmediately is false. The call holds until a terminal or interrupted state.
Where is the result?
In artifacts. A message should not carry a task's output.
Why answer TaskNotFoundError for another caller's task?
The spec forbids revealing that a resource exists.

Tips#

  • Mint a new messageId for each new message. Reuse it only to retry.
  • Send ROLE_USER from the client and ROLE_AGENT from the server.
  • Send historyLength 0 for a status check.
  • Read the card and check its capability flags before an optional call.

One task, step by step#

1Clientsends a blocking SendMessage with a newmessageId and no taskId.2Servercreates the task and mints its taskId andcontextId.3Agentstops at TASK_STATE_INPUT_REQUIRED, and the callreturns the task with its question.4Clientanswers with a second SendMessage with the sametaskId and contextId.5Serverreturns the same task in TASK_STATE_COMPLETED,with its artifact.6Clientcalls GetTask with the taskId to read the storedtask again.

JSON-RPC request#

curl -s http://localhost:41242/a2a/jsonrpc \one URL for every operation
-H 'Content-Type: application/json' \JSON body
-H 'A2A-Version: 1.0' \required on every request
-d '{
"jsonrpc": "2.0",envelope version, always 2.0
"id": 1,the reply repeats this id
"method": "SendMessage",PascalCase operation name
"params": {"message": {
"messageId": "d95bafc8-f2a4-427b-9cf4-bb99f4bea973",minted by the client
"role": "ROLE_USER",the client always sends ROLE_USER
"parts": [{"text": "What languages can you review?"}]at least one part
}}
}'

Troubleshooting#

SymptomCauseFix
-32009 on every callNo A2A-Version headerSend A2A-Version: 1.0
-32601 with message/sendA 0.3 method nameSend SendMessage
-32004 on a finished taskThe task is terminalStart a task with referenceTaskIds in the same context
-32003 on a push config callThe card has no pushNotifications flagRead the card before the call
-32602 with a BadRequest detailmessage.messageId is missingMint a messageId for every message
-32001 or HTTP 404The id is unknown, purged, or hiddenCheck the id, then stop