Scenario
A dropped stream ran the suite twice
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 watches a long test suite through a stream from the test-runner agent. A load balancer sits between them and closes connections that stay open for long. The planner's stream handler came from a REST client, and it has one rule for a connection that drops before the final frame: send the request again. Yesterday the suite of payments-api ran twice for every drop. The CI bill doubled, and a flaky test that passed in the first run failed in the second and blocked a release.
A teammate patched the handler to call SubscribeToTask after a drop and to retry that call on any error. The next time the task had already finished when the handler reconnected, the call returned an error, and the handler logged "this server does not support subscriptions" and turned streaming off for the agent. You have the capture of the same sequence: a stream that the client closes after four frames, the call that picks it up, and a third call after the end.
Questions
- After the first stream closes at frame four, what has happened to the task, and what happens to the events the agent emits next?
- What differs between the two requests, and why does one of them create work while the other does not?
- What does the first frame of the second stream hold, and how does a client merge it with what it already has?
- The third call returns an error. What does it mean, and what is the next call?
- Does a repeated messageId protect the planner here? Why or why not?
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
the first stream, four frames, then the client closes the connection
Each data line is one complete frame. Read the state in frame 1 and 2, the artifact in frames 3 and 4, and the last line.
HTTP/1.1 200 OK
Content-Type: text/event-stream
data: {"jsonrpc": "2.0", "id": 1, "result": {"task": {"id": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "status": {"state": "TASK_STATE_SUBMITTED", "timestamp": "2026-10-06T09:00:04.000Z"}, "history": [{"messageId": "c15521b1-b3dc-450a-9daa-37e51b591d75", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "role": "ROLE_USER", "parts": [{"text": "Run the full suite for payments-api at commit 9f3c2e1"}]}]}}}
data: {"jsonrpc": "2.0", "id": 1, "result": {"statusUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "status": {"state": "TASK_STATE_WORKING", "message": {"messageId": "47206245-9085-4c5c-9899-3f2b41a7a980", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "role": "ROLE_AGENT", "parts": [{"text": "Checking out 9f3c2e1 and starting the suite"}]}, "timestamp": "2026-10-06T09:00:04.250Z"}}}}
data: {"jsonrpc": "2.0", "id": 1, "result": {"artifactUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "artifact": {"artifactId": "test-log", "name": "test-log.txt", "parts": [{"text": "tests/test_suite_01.py ........\n"}]}}}}
data: {"jsonrpc": "2.0", "id": 1, "result": {"artifactUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "artifact": {"artifactId": "test-log", "parts": [{"text": "tests/test_suite_02.py ........\n"}]}, "append": true}}}
# the client closes the connection after 4 eventsSource: manuals/a2a-101/capture/out/14-resubscribe.http, lines 25-36
the request that picks the stream back up
Compare the method and the params with the first request. There is no message here.
### 2 · SubscribeToTask: pick the stream back up
POST /a2a/jsonrpc HTTP/1.1
Host: localhost:41241
Content-Type: application/json
A2A-Version: 1.0
Accept: text/event-stream
{
"jsonrpc": "2.0",
"id": 2,
"method": "SubscribeToTask",
"params": {
"id": "25239d4c-798b-4754-be06-d1f94d0645b1"
}
}Source: manuals/a2a-101/capture/out/14-resubscribe.http, lines 38-52
the second stream, six frames to the end
Read the member of frame 1, the test file names in frames 2 to 5, and the state in frame 6.
HTTP/1.1 200 OK
Content-Type: text/event-stream
data: {"jsonrpc": "2.0", "id": 2, "result": {"task": {"id": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "status": {"state": "TASK_STATE_WORKING", "message": {"messageId": "47206245-9085-4c5c-9899-3f2b41a7a980", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "role": "ROLE_AGENT", "parts": [{"text": "Checking out 9f3c2e1 and starting the suite"}]}, "timestamp": "2026-10-06T09:00:04.250Z"}, "history": [{"messageId": "c15521b1-b3dc-450a-9daa-37e51b591d75", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "role": "ROLE_USER", "parts": [{"text": "Run the full suite for payments-api at commit 9f3c2e1"}]}], "artifacts": [{"artifactId": "test-log", "name": "test-log.txt", "parts": [{"text": "tests/test_suite_01.py ........\n"}, {"text": "tests/test_suite_02.py ........\n"}, {"text": "tests/test_suite_03.py ........\n"}, {"text": "tests/test_suite_04.py ........\n"}]}]}}}
data: {"jsonrpc": "2.0", "id": 2, "result": {"artifactUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "artifact": {"artifactId": "test-log", "parts": [{"text": "tests/test_suite_05.py ........\n"}]}, "append": true}}}
data: {"jsonrpc": "2.0", "id": 2, "result": {"artifactUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "artifact": {"artifactId": "test-log", "parts": [{"text": "tests/test_suite_06.py ........\n"}]}, "append": true}}}
data: {"jsonrpc": "2.0", "id": 2, "result": {"artifactUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "artifact": {"artifactId": "test-log", "parts": [{"text": "tests/test_suite_07.py ........\n"}]}, "append": true}}}
data: {"jsonrpc": "2.0", "id": 2, "result": {"artifactUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "artifact": {"artifactId": "test-log", "parts": [{"text": "tests/test_suite_08.py ........\n"}]}, "append": true, "lastChunk": true}}}
data: {"jsonrpc": "2.0", "id": 2, "result": {"statusUpdate": {"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "status": {"state": "TASK_STATE_COMPLETED", "message": {"messageId": "b9264586-875b-4914-992a-7a26235a16ba", "contextId": "ed92749e-5686-4e20-a1cf-d3b2aee3b1da", "taskId": "25239d4c-798b-4754-be06-d1f94d0645b1", "role": "ROLE_AGENT", "parts": [{"text": "96 passed"}]}, "timestamp": "2026-10-06T09:00:04.500Z"}}}}Source: manuals/a2a-101/capture/out/14-resubscribe.http, lines 54-67
the artifact inside the first frame of the second stream
Count the parts and compare them with the two the first stream carried.
"artifacts": [
{
"artifactId": "test-log",
"name": "test-log.txt",
"parts": [
{
"text": "tests/test_suite_01.py ........\n"
},
{
"text": "tests/test_suite_02.py ........\n"
},
{
"text": "tests/test_suite_03.py ........\n"
},
{
"text": "tests/test_suite_04.py ........\n"
}
]
}
]
}Source: manuals/a2a-101/capture/out/14-resubscribe.events.json, lines 137-157
a third SubscribeToTask after the task completed, status and code
Read the content type and the code.
HTTP/1.1 200 OK
Content-Type: application/json
{
"jsonrpc": "2.0",
"id": 3,
"error": {
"code": -32004,
"message": "This operation is not supported",
"data": [
{Source: manuals/a2a-101/capture/out/14-resubscribe.http, lines 85-95
the detail inside that error
The reason and the state in the metadata.
"reason": "UNSUPPORTED_OPERATION",
"domain": "a2a-protocol.org",
"metadata": {
"taskId": "25239d4c-798b-4754-be06-d1f94d0645b1",
"state": "TASK_STATE_COMPLETED"
}
}
]
}Source: manuals/a2a-101/capture/out/14-resubscribe.http, lines 97-105
what a repeated messageId does on every implementation
Read the last sentence.
Send Message operations are allowed to be idempotent, and an agent can use the `messageId` to find duplicate messages {{spec §3.3.1}}. So a retry of a send that timed out can reuse the same `messageId`. No SDK rejects a repeated id, and without a `taskId` each one creates another task for it.Source: manuals/a2a-101/sections/3-1-message.md, lines 84-84
The answer
Show the walkthrough
- Read the first stream. Four frames arrive: a
taskinTASK_STATE_SUBMITTED, astatusUpdatetoTASK_STATE_WORKING, anartifactUpdatethat openstest-log.txtwith the first test file, and anartifactUpdatethat appends the second file. Then the kit's note says that the client closed the connection. No frame carried a terminal state, so the task is alive. The lifecycle of a task does not depend on any one stream. The agent goes on and appends two more files to its stored artifact, and those events have no open connection to travel on. - Read the second request. The method is
SubscribeToTask, and the params hold only the task id. There is no message and nomessageId. This call opens a view on work that exists and creates nothing. The planner's old handler sent a newSendStreamingMessageinstead, and a message without ataskIdstarts a new task every time. - Read the second stream. Frame 1 is a complete
taskobject, still inTASK_STATE_WORKING. Itstest-logartifact already holds four parts,test_suite_01totest_suite_04, which includes the two files the first stream never carried. Frames 2 to 5 appendtest_suite_05totest_suite_08, and the last one setslastChunk. Frame 6 is astatusUpdatetoTASK_STATE_COMPLETEDwith96 passed. Nothing is replayed, and the protocol has no cursor. The client replaces its partial log with the snapshot's artifact and then appends the frames that follow. - Read the third call. The reply has
Content-Type: application/json, not an event stream. It is anerrorwith code -32004 and the reasonUNSUPPORTED_OPERATION, and the metadata names the stateTASK_STATE_COMPLETED. This is the terminal-task case of that code, not a missing feature. The client stops reconnecting and reads the final task withGetTask. - Check the id rule. A retry of a send whose reply never came may reuse the same
messageId. No implementation rejects a repeated id, and without ataskIdeach copy creates another task. So the id protects the planner only against a send that may not have arrived. Here the task exists, the client holds its id, and the right call is a subscribe, not a send.
Show the resolution
The reconnect rule caused the double run. A SendStreamingMessage is a command plus a view, and resending the command repeats the work. The fix has four parts. A closed connection ends the reading and nothing else. If the last frame was not a terminal state, the handler calls SubscribeToTask with the task id. It rebuilds its copy from the task snapshot in the first frame and appends what follows. On -32004 it stops reconnecting and calls GetTask. The capture is the proof: one task id runs through both streams, the resumed stream delivers the four missing files and the final 96 passed, and the agent ran the suite once.
Show the wrong turns
“On a drop, send the request again.”
The request carries a message, and a message without a task id starts a new task. The suite runs again.
“Resend with the same messageId, and the server will drop the duplicate.”
Duplicate detection is optional, no implementation rejects a repeated id, and each copy without a task id makes a new task.
“The connection closed, so the task is finished.”
Only a terminal state in a frame ends a task. The kit also closes at an input request, and servers differ on when they close. Call
GetTaskafter any close.“-32004 means this server has no SubscribeToTask.”
The metadata names the completed state. The result is one
GetTaskaway.“Append the new frames to the old partial log.”
Two files were written while no connection was open. The snapshot holds them, so replace the copy first and append after.
Show the general rule
Keep the work and the view of the work apart. A command that creates work must go out once, and a reconnect must open a view by the id of the work, never repeat the command. Resume from a snapshot that the server owns, and let a terminal state in the data, not the end of a connection, tell you that the work is done.
Taught in
The streaming page of A2A 101 follows this drop and the subscribe that recovers it, the message page explains what each implementation does with a repeated messageId, and the failure modes lesson lists the repeated step among the ways an agent loop goes wrong.