Skip to content

fix(server): fail streaming sends when an executor produces no events - #1460

Merged
Iwaniukooo11 merged 2 commits into
a2aproject:mainfrom
1AbdullahButt:fix/stream-no-events
Nov 16, 2026
Merged

Iwaniukooo11 merged 2 commits into
a2aproject:mainfrom
1AbdullahButt:fix/stream-no-events

Conversation

@1AbdullahButt

Copy link
Copy Markdown
Contributor

Description

Since #1345, on_message_send raises InvalidAgentResponseError ("Agent execution produced no events") when the AgentExecutor returns without producing any event. on_message_send_stream did not have the same guard: its subscription ended with nothing yielded, so SendStreamingMessage answered 200 text/event-stream with zero events. Spec §3.1.2 requires the stream to begin with a Task or contain exactly one Message.

This PR applies the same check at the end of on_message_send_stream: when the subscription yielded no event and no task was created, it raises InvalidAgentResponseError. The JSON-RPC and REST dispatchers already read the first event eagerly, so the client now gets the same error as the non-streaming call (JSON-RPC -32006, REST 500 INVALID_AGENT_RESPONSE) instead of an empty stream. Executors that produce events are unaffected.

Tests: test_on_message_send_stream_raises_when_agent_produces_no_events reuses the SilentExecutor from the #1345 test.

$ pytest tests/server/request_handlers/test_default_request_handler_v2.py -k no_events   # handler from main
1 failed, 1 passed
$ pytest tests/server/request_handlers/test_default_request_handler_v2.py -k no_events   # this branch
2 passed
$ pytest tests/server tests/integration
1460 passed; the same 4 failures and 8 errors as on unmodified main (sample smoke tests and database tests that need services I don't have locally)

I also checked it over HTTP with a silent executor behind create_jsonrpc_routes and create_rest_routes: before, both streaming endpoints returned an empty 200 stream; after, JSON-RPC returns the -32006 error and REST returns 500 with reason INVALID_AGENT_RESPONSE.

ruff check, ruff format and ty check pass on the changed files.

This change was written with Claude Code.

Fixes #1459 🦕

🤖 Generated with Claude Code

on_message_send raises InvalidAgentResponseError when the executor
returns without producing any event (a2aproject#1345), but on_message_send_stream
ended with an empty stream instead. A streaming send must start with a
Task or Message, so the client got a successful stream with nothing in
it.

Raise the same InvalidAgentResponseError when the subscription ends
without yielding an event and no task was created. The JSON-RPC and
REST dispatchers read the first event eagerly, so this becomes a -32006
error response like the non-streaming call.

Fixes a2aproject#1459

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1AbdullahButt
1AbdullahButt requested a review from a team as a code owner November 12, 2026 19:41
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/request_handlers/default_request_handler_v2.py 88.60% 88.78% 🟢 +0.17%
Total 93.67% 93.67% ⚪️ 0.00%

Generated by coverage-comment.yml

@Iwaniukooo11 Iwaniukooo11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Iwaniukooo11
Iwaniukooo11 merged commit c16cab1 into a2aproject:main Nov 16, 2026
17 checks passed
Linux2010 added a commit to Linux2010/a2a-python that referenced this pull request Nov 16, 2026
The non-streaming guard moved to default_request_handler_v2.py:522-527
after a2aproject#1460 added the streaming-side counterpart; both callers now
guard, which claim 5 notes.

Signed-off-by: andy <linux2011@qq.com>
Linux2010 added a commit to Linux2010/a2a-python that referenced this pull request Nov 16, 2026
The non-streaming guard moved to default_request_handler_v2.py:522-527
after a2aproject#1460 added the streaming-side counterpart; both callers now
guard, which claim 5 notes.

Signed-off-by: andy <linux2011@qq.com>
Iwaniukooo11 pushed a commit that referenced this pull request Nov 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.3.1](v1.3.0...v1.3.1)
(2026-11-16)


### Features

* add httpx2 support
([#1439](#1439))
([a59bb68](a59bb68))
* **cluster:** Introduce ServerCallContext to DatabaseTaskEventStream
([#1399](#1399))
([6168d59](6168d59))


### Bug Fixes

* **client:** handle case-insensitive SSE media types
([#1464](#1464))
([3932982](3932982))
* **client:** keep tenant defaults local to each call
([#1463](#1463))
([569b94f](569b94f))
* **client:** percent-encode ids in REST transport paths
([#1436](#1436))
([1bbe69c](1bbe69c))
* **client:** split SSE lines only on CR, LF and CRLF
([#1456](#1456))
([c8ccea9](c8ccea9))
* **compat:** get a v0.3 push config by task id alone
([#1380](#1380))
([aa8e966](aa8e966))
* **compat:** list push notification configs in the v0.3 REST client
([#1424](#1424))
([d830036](d830036)),
closes [#1423](#1423)
* **compat:** map v0.3 gRPC errors from their ErrorInfo reason
([#1466](#1466))
([caab6a2](caab6a2))
* **compat:** parse the v0.3 REST extended agent card as JSON
([#1420](#1420))
([076e0ec](076e0ec))
* **compat:** percent-encode ids in v0.3 REST transport paths
([#1458](#1458))
([1ff86d5](1ff86d5))
* **compat:** return -32602 for invalid v0.3 JSON-RPC params
([#1419](#1419))
([05aaff6](05aaff6))
* **compat:** return 400 for a non-integer v0.3 REST historyLength
([#1382](#1382))
([9c90c48](9c90c48)),
closes [#1381](#1381)
* **compat:** return HTTP errors from v0.3 REST streams that fail early
([#1403](#1403))
([11f1116](11f1116))
* **compat:** send no v0.3 configuration when the request has none
([#1429](#1429))
([01483cb](01483cb))
* **compat:** send v0.3 REST request bodies with json_name keys
([#1455](#1455))
([2399993](2399993))
* **compat:** serve DELETE for v0.3 REST push notification configs
([#1442](#1442))
([14e799c](14e799c))
* reject decoded values that are not objects in parse_lenient
([#1431](#1431))
([257626b](257626b))
* reject invalid REST boolean query values
([#1383](#1383))
([babc3f5](babc3f5))
* **server:** close the event queues when ActiveTask.start() fails
([#1422](#1422))
([5e0d415](5e0d415))
* **server:** create the cluster tables lazily in
VersionedDatabaseTaskStore get and delete
([#1357](#1357))
([4e133b7](4e133b7))
* **server:** fail fast when an executor produces no events
([#1345](#1345))
([ab7e36f](ab7e36f))
* **server:** fail streaming sends when an executor produces no events
([#1460](#1460))
([c16cab1](c16cab1))
* **server:** forward CancelTaskRequest.metadata to AgentExecutor.cancel
([#1416](#1416))
([f666ba3](f666ba3)),
closes [#1415](#1415)
* **server:** infer contextId from task when only taskId is provided
([#1453](#1453))
([2ba8e7b](2ba8e7b)),
closes [#1411](#1411)
* **server:** match input modes on type and subtype, ignoring case
([#1425](#1425))
([28f8a62](28f8a62))
* **server:** prevent failed cancel from overwriting terminal task state
([#1405](#1405))
([ac48ce1](ac48ce1))
* **server:** record FAILED when a task's terminal save fails
([#1400](#1400))
([4e916d8](4e916d8))
* **server:** reject out-of-range ListTasks cursor timestamps
([#1451](#1451))
([f451ed7](f451ed7))
* **server:** run after_handler_run when a handler call is cancelled
([#1427](#1427))
([2cc1dd5](2cc1dd5))
* **server:** treat request bodies that are not valid UTF-8 as parse
errors ([#1401](#1401))
([56ec855](56ec855))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Linux2010 added a commit to Linux2010/a2a-python that referenced this pull request Nov 17, 2026
The non-streaming guard moved to default_request_handler_v2.py:522-527
after a2aproject#1460 added the streaming-side counterpart; both callers now
guard, which claim 5 notes.

Signed-off-by: andy <linux2011@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SendStreamingMessage returns an empty 200 stream when the executor produces no events

2 participants