Skip to content

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

Open
1AbdullahButt wants to merge 1 commit into
a2aproject:mainfrom
1AbdullahButt:fix/stream-no-events
Open

1AbdullahButt wants to merge 1 commit 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 <[email protected]>
@1AbdullahButt
1AbdullahButt requested a review from a team as a code owner November 12, 2026 19:41
@github-actions

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.34% 88.52% 🟢 +0.18%
Total 93.56% 93.57% ⚪️ 0.00%

Generated by coverage-comment.yml

@Iwaniukooo11 Iwaniukooo11 self-assigned this Nov 13, 2026

This branch has not been deployed

No deployments
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