Repository navigation
Description
What happened?
Summary
When SubscribeToTask is called on a task in a terminal state, the SUT opens a stream and delivers the UnsupportedOperationError inside it instead of returning a direct error response. Since the server knows upfront that the task cannot be subscribed to, it should reject the request immediately.
Requirement
- ID: STREAM-SUB-003
- Section: 3.1.6 — SubscribeToTask rejects terminal tasks
- Level: MUST
- Spec: Section 3.1.6 Subscribe to Task
Specification
Errors:
UnsupportedOperationError: The operation is attempted on a task that is in a terminal state (completed,failed,canceled, orrejected).
And from Section 9.4.6:
Error: Returns
UnsupportedOperationErrorif the task is in a terminal state (completed,failed,canceled, orrejected).
Expected behavior
When SubscribeToTask is called on a task already in a terminal state, the server should return an immediate error response (not open a stream), since it knows upfront that the subscription is invalid.
JSON-RPC — expected: Direct JSON-RPC error response:
{
"jsonrpc": "2.0",
"id": 3,
"error": {
"code": -32004,
"message": "Cannot subscribe to task - task is in terminal state"
}
}HTTP+JSON — expected: 400 Bad Request with an error body (no SSE stream).
gRPC — expected: Immediate UNIMPLEMENTED status code without opening the stream.
Actual behavior
All three transports open a stream and deliver the error inside it:
JSON-RPC — actual: HTTP 200 with SSE stream containing error event:
: SSE stream started
data: {"jsonrpc":"2.0","id":3,"error":{"code":-32004,"message":"Cannot subscribe to task ... - task is in terminal state: TASK_STATE_COMPLETED"}}
id: 0
HTTP+JSON — actual: HTTP 200 with SSE stream containing error event:
: SSE stream started
data: {"error":{"code":400,"status":"UNIMPLEMENTED","message":"Cannot subscribe to task ... - task is in terminal state: TASK_STATE_COMPLETED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"UNSUPPORTED_OPERATION","domain":"a2a-protocol.org","metadata":{}}]}}
id: 0
gRPC — actual: Stream opens, then terminates with UNIMPLEMENTED status during iteration:
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.UNIMPLEMENTED
details = "Cannot subscribe to task ... - task is in terminal state: TASK_STATE_COMPLETED"
>
Reproducer
# Step 1: Create a task that completes immediately
curl -s -X POST http://localhost:9999 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0","id":1,"method":"SendMessage",
"params":{"message":{"role":"ROLE_USER","parts":[{"text":"TCK prerequisite"}],"messageId":"tck-complete-task-repro-001"}}
}'
# Note the task ID from result.task.id
# Step 2: Verify the task is in a terminal state
TASK_ID="<task-id-from-step-1>"
curl -s -X POST http://localhost:9999 \
-H "Content-Type: application/json" \
-d "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"GetTask\",\"params\":{\"id\":\"$TASK_ID\"}}"
# Confirm status.state is TASK_STATE_COMPLETED
# Step 3: SubscribeToTask on the terminal task
# Expected: direct JSON-RPC error response with code -32004
# Actual: SSE stream opens (HTTP 200) and error is delivered as a stream event
curl -s -X POST http://localhost:9999 \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"SubscribeToTask\",\"params\":{\"id\":\"$TASK_ID\"}}"TCK test
tests/compatibility/core_operations/test_task_lifecycle.py::TestSubscribeLifecycle::test_subscribe_rejects_terminal_task[grpc]tests/compatibility/core_operations/test_task_lifecycle.py::TestSubscribeLifecycle::test_subscribe_rejects_terminal_task[jsonrpc]tests/compatibility/core_operations/test_task_lifecycle.py::TestSubscribeLifecycle::test_subscribe_rejects_terminal_task[http_json]
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
jmesnil commentedon Apr 13, 2026
This issue is a bit ambiguous. Currently the error is delivered by the event stream and not the HTTP response to the
SubscribeToTaskoperation.It's not 100% clear from the spec where the error should be returned.
I think returning the error in the HTTP response makes sense since the remote agent knows from the get go that it is not correct to subscribe to a terminal task.
ehsavoie commentedon Apr 13, 2026
@jmesnil I'm wondering about this behaviour as for STREAM-SUB-004 you are expecting the TaskNotFound error to be in the stream
jmesnil commentedon Apr 13, 2026
@ehsavoie what do you mean? The test for STREAM-SUB-004 is at https://github.com/a2aproject/a2a-tck/blob/1f9f4a21ac9bb53341a2292007b423f32c56d724/tests/compatibility/jsonrpc/test_sse_streaming.py#L172.
It looks for either the error in the HTTP response or the event stream.
Depending on the resolution of #791, the test for STREAM-SUB-004 would have to be updated to look for a consistent place for the error. I can also open a spec issue to clarify any ambiguity
jmesnil commentedon Apr 14, 2026
Actually, the spec is not ambiguous about this.
In https://a2a-protocol.org/latest/specification/#316-subscribe-to-task, it says that the output of
SubscribeToTaskis:A
StreamResponsecan not contain an error. This means that the error MUST be returned by the HTTP response (and the stream is never open in that case)fix: improve SSE error handling and add early task validation
fix: improve SSE error handling and add early task validation
fix: improve SSE error handling and add early task validation
fix: improve SSE error handling and add early task validation
fix: Fixing last TCK issues (#795)
fix: Fixing last TCK issues (a2aproject#795)
fix(jsonrpc): don't open a stream when streaming is not supported (#1356