By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
When you send a message to a remote agent, you need to know what you're actually calling, how to handle the response, and what protocol you're using to get there. The A2A spec answers this by separating the data model from the operations from the wire format. Understanding these three layers keeps you from mixing concerns and helps you pick the right retrieval pattern for your use case.
The spec defines three distinct layers, each independent of the others.
Layer 1 is the canonical data model: Task, Message, Part, Artifact, AgentCard. These are defined once in Protocol Buffers and stay the same everywhere. Layer 2 is the abstract operations: SendMessage, GetTask, ListTasks, CancelTask, SubscribeToTask, push-notification config, GetExtendedAgentCard. These describe what you can do, not how you do it. Layer 3 is the protocol bindings: JSON-RPC 2.0, gRPC, HTTP + JSON (REST). Each binding translates the same operations into its own syntax.
The same operation has different names per binding. Over REST, you POST to .../message:send to send a message and GET .../tasks/{id} to fetch a task. Over JSON-RPC, you call SendMessage and GetTask. Older clients used message/send and tasks/get, and many servers still accept those aliases for compatibility.
When you call SendMessage, the remote agent receives your message and decides whether to answer directly or track the work as a task. If it returns a Task, you now have a task ID and a state.
{
"jsonrpc": "2.0", "id": 1, "method": "SendMessage",
"params": {
"message": {
"role": "ROLE_USER",
"messageId": "m-001",
"parts": [ { "text": "Book me BLR to DEL next Monday morning" } ]
},
"configuration": { "returnImmediately": true }
}
}// response: a Task (the agent chose to track this as work)
{ "jsonrpc": "2.0", "id": 1,
"result": { "task": {
"id": "t-77", "contextId": "c-12",
"status": { "state": "TASK_STATE_WORKING" }
} } }The response is either a Message (a direct answer) or a Task. The configuration parameter returnImmediately controls whether you wait. Set it to true and the call returns as soon as the task object exists, even if the agent is still working. Set it to false (or omit it) and the call blocks until the task reaches a terminal state.
Once you have a task ID, you need a strategy to get the result. The spec supports three patterns, each with different tradeoffs.
Blocking is the simplest: you call SendMessage with returnImmediately false (or default) and wait for the response. Use this for short tasks where latency is not a problem. Polling is robust and firewall-friendly: you call SendMessage with returnImmediately true, get the task ID back immediately, then call GetTask on a timer until the task finishes. Streaming delivers live updates over Server-Sent Events: you call SendStreamingMessage and get status updates and artifact chunks as they arrive. Alternatively, call SubscribeToTask to attach to an existing task and stream its remaining updates. If the task is already finished, subscribing is an error; use GetTask instead. Push notifications are for very long tasks: you register a webhook and the remote agent calls you back when something changes.
A task can pause and ask for more information. This is not an error state; it is a continuation of the conversation.
When a task reaches INPUT_REQUIRED or AUTH_REQUIRED, the agent is waiting for you. You send another message with the same taskId and provide the missing information, authenticate, or cancel. The agent resumes from where it paused.
Your polling or streaming loop needs to handle different task states. Some states mean you are done, some mean you need to act, and some mean you should keep waiting.
TERMINAL = {"TASK_STATE_COMPLETED", "TASK_STATE_FAILED",
"TASK_STATE_CANCELED", "TASK_STATE_REJECTED"}
INTERRUPTED = {"TASK_STATE_INPUT_REQUIRED", "TASK_STATE_AUTH_REQUIRED"}
def classify(state):
if state in TERMINAL: return "done" # read artifacts or the error
if state in INTERRUPTED: return "needs-caller" # answer, authenticate or cancel
return "keep-waiting"Terminal states (COMPLETED, FAILED, CANCELED, REJECTED) mean the task is over. Read the artifacts or the error and move on. Interrupted states (INPUT_REQUIRED, AUTH_REQUIRED) mean the remote agent is waiting for you. Respond, authenticate, or cancel. Any other state means the task is still working; keep waiting or check again later.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.