Scenario
An hour of polling a task that waited for us
RolesAgent Systems EngineeringCustomer AI Deployment
- Engine
- A2A 1.0.1 with the manual's capture kit (the test-runner, code-reviewer and deployer agents)
- Model
- no model; the agents are deterministic fixtures
- Hardware
- one machine, localhost, no network
Situation
A planner sends a diff of payments-api to the code-reviewer agent and waits for the findings. Its wait loop is the one it uses for every remote agent: send the message, then call GetTask every few seconds until the state is completed, failed or canceled. Last night a review never came back. The planner polled the same task for an hour, then its own run timed out, and the release waited for a human reviewer in the morning.
The on-call engineer pulls the first reply that the reviewer sent. It was not a failure, and the agent never went quiet. The planner knew the branch the diff was cut from, because it had checked the code out itself. You have the two exchanges of the review from the capture kit, a polling exchange on another agent for comparison, and the log of the kit's own planner, which handled the same question in its run.
Questions
- What state did the first reply carry, and who wrote the message inside it?
- How does a task that waits for input differ from one that is working, when you look at two polls?
- Where does the planner's answer go, and which fields must it carry?
- Which states must a wait loop stop on, and what is the next step for each of them?
- The planner had the branch name in its own context. Why did the loop never use it?
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
the reply to the review request
Read the state, the role of the status message, and what it asks.
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"task": {
"id": "e5c95b09-6d4b-4b3b-8693-91e81472d12f",
"contextId": "49c5a238-4158-455d-8d63-b2cb39c0ecac",
"status": {
"state": "TASK_STATE_INPUT_REQUIRED",
"message": {
"messageId": "46494a30-e224-4d71-8d6f-50c110597e3b",
"contextId": "49c5a238-4158-455d-8d63-b2cb39c0ecac",
"taskId": "e5c95b09-6d4b-4b3b-8693-91e81472d12f",
"role": "ROLE_AGENT",
"parts": [
{
"text": "Which base branch should I compare this diff against?"
}
]
},
"timestamp": "2026-10-06T09:00:00.500Z"
},Source: manuals/a2a-101/capture/out/06-input-required.http, lines 32-53
a GetTask on a task that is still running, from another capture
Compare this state and status message with the ones in the review reply.
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"id": "d0c28826-28b8-4b15-8b53-4e01ae7a5a3c",
"contextId": "3afa8576-7a83-4167-bb58-01c3b0942c8f",
"status": {
"state": "TASK_STATE_WORKING",
"message": {
"messageId": "fb999be8-dce9-416b-b397-d74b090f121a",
"contextId": "3afa8576-7a83-4167-bb58-01c3b0942c8f",
"taskId": "d0c28826-28b8-4b15-8b53-4e01ae7a5a3c",
"role": "ROLE_AGENT",
"parts": [
{
"text": "Checking out 9f3c2e1 and starting the suite"
}
]
},
"timestamp": "2026-10-06T09:00:01.250Z"
},
"artifacts": [
{
"artifactId": "test-log",
"name": "test-log.txt",
"parts": [
{
"text": "collected 12 items\n"
}
]
}
]
}
}Source: manuals/a2a-101/capture/out/04-polling.http, lines 77-110
the message that answers the question
Read which ids the message carries and where they came from.
{
"jsonrpc": "2.0",
"id": 2,
"method": "SendMessage",
"params": {
"message": {
"messageId": "096d3737-42f9-4039-8320-a4737c2b3abe",
"contextId": "49c5a238-4158-455d-8d63-b2cb39c0ecac",
"taskId": "e5c95b09-6d4b-4b3b-8693-91e81472d12f",
"role": "ROLE_USER",
"parts": [
{
"text": "main"
}
]
}
}
}Source: manuals/a2a-101/capture/out/06-input-required.http, lines 82-99
the reply to the answer
Same task id, new state, new status message.
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"task": {
"id": "e5c95b09-6d4b-4b3b-8693-91e81472d12f",
"contextId": "49c5a238-4158-455d-8d63-b2cb39c0ecac",
"status": {
"state": "TASK_STATE_COMPLETED",
"message": {
"messageId": "cdf017cb-27ab-4cd1-9b83-6d0995c9da8b",
"contextId": "49c5a238-4158-455d-8d63-b2cb39c0ecac",
"taskId": "e5c95b09-6d4b-4b3b-8693-91e81472d12f",
"role": "ROLE_AGENT",
"parts": [
{
"text": "2 findings"
}
]
},
"timestamp": "2026-10-06T09:00:01.250Z"
},Source: manuals/a2a-101/capture/out/06-input-required.http, lines 104-125
how the kit's planner handled the same question
Five lines, from the delegation to the review result.
delegate review-diff to code-reviewer
task 80bc7784 is TASK_STATE_INPUT_REQUIRED
it asks: Which base branch should I compare this diff against? The planner answers from its own context: main
task 80bc7784 is TASK_STATE_COMPLETED
review: 1 finding, 0 blockingSource: manuals/a2a-101/capture/out/19-planner.log, lines 7-11
the nine states, their class, and the client's next step
Find the two interrupted rows and read their last column.
| State | Class | Set by | The client does next |
|---|---|---|---|
| TASK_STATE_UNSPECIFIED | none | Nobody: the zero value | Treat it, and any unknown name, as an error. |
| TASK_STATE_SUBMITTED | active | The server, on creation | Wait, poll, or subscribe. |
| TASK_STATE_WORKING | active | The agent, while it works | As for a submitted task |
| TASK_STATE_INPUT_REQUIRED | interrupted | The agent, with a question | Answer with a new message that carries the same `taskId` and `contextId`. |
| TASK_STATE_AUTH_REQUIRED | interrupted | The agent, for an authorization | Pass the request to whoever approves it, outside A2A, and subscribe, register a webhook, or poll. |
| TASK_STATE_COMPLETED | terminal | The agent, when the work is done | Read the artifacts for the result. Follow up in a new task with `referenceTaskIds`. |
| TASK_STATE_FAILED | terminal | The agent, unable to do the work | Read the status message, fix the input, and start a new task. |
| TASK_STATE_CANCELED | terminal | The agent, after `CancelTask` | Start a new task in the same context. |
| TASK_STATE_REJECTED | terminal | The agent, refusing the task | Stop the loop, and follow the status message. |Source: manuals/a2a-101/sections/r-3-task-states.md, lines 7-17
why the answer carries both ids
One sentence on what the implementations do with a message that names only the task.
Five SDKs infer the context for the agent and store the message as sent, and the reference SDK generates a new one. Send both ids, and the difference never reaches you.Source: manuals/a2a-101/sections/3-1-message.md, lines 95-95
The answer
Show the walkthrough
- Read the first reply. The state is
TASK_STATE_INPUT_REQUIRED. The status message has the roleROLE_AGENTand asks which base branch the diff should be compared against. A blocking send returns at a terminal or an interrupted state, so the question was in the planner's hands from the first reply, before the first poll. - Compare with a working task. In the polling capture the state is
TASK_STATE_WORKING, the status message reports progress, and the artifact grows between polls. A parked task does none of that. Its state is the agent saying "your turn", and no number of polls changes it. - Read the answer. It is an ordinary
SendMessage. The message has a freshmessageId, the roleROLE_USER, the textmain, and both thecontextIdand thetaskIdcopied from the task. The reference SDK does not infer the context from the task and stamps a fresh one, so a client sends both ids. - Read the second reply. The same task id comes back in
TASK_STATE_COMPLETEDwith the status message2 findings. The history now holds the question and the answer, and thereview.jsonartifact namesmainas the base and lists the two findings with their lines. The task never left its id or its context. - Read the planner log. The kit's planner sees the interrupted state, reads the question, answers from its own context with
main, and reports the review one call later. The interrupted state is a branch in its loop, not a reason to wait. - Read the state table. Nine states fall in three classes. Two are interrupted, and each has a different next step: answer on the same task for input, or pass the request to an approver and keep watching for authorization. Four are terminal, and the fourth, rejected, is the one most loops forget.
Show the resolution
The loop had the wrong stop set. It waited for three terminal states and treated everything else as "still running", so an interrupted task looked like a slow one. The fix adds the two interrupted states to the stop set and gives each a branch. For TASK_STATE_INPUT_REQUIRED, the planner reads the status message and answers with a new message that carries the task id and the context id of the parked task. For TASK_STATE_AUTH_REQUIRED, it hands the request to whoever approves and subscribes or polls. For TASK_STATE_REJECTED, it stops and follows the message. The capture proves the path: the reviewer finished one call after the answer and returned the review artifact, and the kit's planner log shows the same handling end to end.
Show the wrong turns
“Poll faster, the reviewer is slow.”
The state says that the agent waits for the client. The poll rate does not move it.
“Abandon the task and send a new request with the branch in it.”
It works, and it leaves a parked task behind on the agent, resends the diff, and loses the history. The protocol's path is a new message on the same task.
“Answer with the taskId only; the server knows the context.”
The reference SDK stamps a fresh context on such a message. Copy both ids.
“Treat an interrupted state as a failure and report it.”
The task kept its id, its history and its artifacts. Nothing failed, and the answer finishes it.
“Send the answer as ROLE_AGENT, because the planner is an agent.”
The role is the direction of the message, not the kind of party. The client side is
ROLE_USER, and the kit refuses the other role with -32602.
Show the general rule
A wait loop must know every state the other side can enter, and it must stop on each state that asks something of the caller, not only on the states that end the work. When a remote system pauses with a question, the answer is often already in the caller's context, and the loop is the only thing that stands between the two.
Taught in
The interrupted states page of A2A 101 follows this review from the question to the answer, the task state page and the state table classify the nine states, the message page gives the id rules, and the failure modes lesson names context loss as one of the five ways an agent loop breaks.