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
Protocol architecture#
Send and read a task#
| Task | Code |
|---|---|
| Read the agent card | GET / |
| Send one message | "method": "SendMessage" posted to /a2a/jsonrpc |
| Send the version | A2A-Version: 1.0 |
| Send and return at once | "returnImmediately": true in configuration |
| Open a stream | "method": "SendStreamingMessage" |
Commands over HTTP+JSON#
| Command | What it does |
|---|---|
POST / | Sends a message. The reply is a task or a message. |
POST / | Asks the server to stop a task that is not terminal. |
GET / | Reads the agent card from the well-known path. |
POST / | Returns a task error when the task is already terminal. |
Settings and defaults#
| Setting | Default | Note |
|---|---|---|
returnImmediately | false | A send waits for a terminal or interrupted state |
historyLength | unset | The server decides how much history to return. 0 returns no history. |
pageSize | 50 | The maximum in ListTasks is 100 |
includeArtifacts | false | Artifacts are left out of list results |
A2A-Version | 1.0 | Required on every request, with no patch number |
Compare the bindings#
| Factor | JSON-RPC | HTTP+JSON | gRPC |
|---|---|---|---|
| Operation named by | method, such as SendMessage | route, such as POST /message:send | rpc SendMessage in A2AService |
| Where it is sent | one URL, /a2a/jsonrpc in the kit | one route per operation | lf.a2a.v1.A2AService over HTTP/2 with TLS |
| Stream frame | a data: line with a full JSON-RPC response | a data: line with the StreamResponse alone | a server-streaming rpc of StreamResponse |
TaskNotFoundError | -32001 with HTTP 200 | HTTP 404 | NOT_FOUND |
| Version header | A2A-Version header | A2A-Version header | a2a-version metadata key |
Task states#
- Active
TASK_STATE_SUBMITTEDandTASK_STATE_WORKING. The agent is still working.- Interrupted
TASK_STATE_INPUT_REQUIREDandTASK_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
returnImmediatelyis 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
TaskNotFoundErrorfor another caller's task? - The spec forbids revealing that a resource exists.
Tips#
- Mint a new
messageIdfor each new message. Reuse it only to retry. - Send
ROLE_USERfrom the client andROLE_AGENTfrom the server. - Send
historyLength0 for a status check. - Read the card and check its capability flags before an optional call.
One task, step by step#
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#
| Symptom | Cause | Fix |
|---|---|---|
-32009 on every call | No A2A-Version header | Send A2A-Version: 1.0 |
-32601 with message/send | A 0.3 method name | Send SendMessage |
-32004 on a finished task | The task is terminal | Start a task with referenceTaskIds in the same context |
-32003 on a push config call | The card has no pushNotifications flag | Read the card before the call |
-32602 with a BadRequest detail | message.messageId is missing | Mint a messageId for every message |
-32001 or HTTP 404 | The id is unknown, purged, or hidden | Check the id, then stop |