Repository navigation
fix(server): fail streaming sends when an executor produces no events - #1460
Open
1AbdullahButt wants to merge 1 commit into
Open
1AbdullahButt wants to merge 1 commit into
1AbdullahButt wants to merge 1 commit into
Conversation
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]>
🧪 Code Coverage (vs
|
| 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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since #1345,
on_message_sendraisesInvalidAgentResponseError("Agent execution produced no events") when theAgentExecutorreturns without producing any event.on_message_send_streamdid not have the same guard: its subscription ended with nothing yielded, soSendStreamingMessageanswered200 text/event-streamwith zero events. Spec §3.1.2 requires the stream to begin with aTaskor contain exactly oneMessage.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 raisesInvalidAgentResponseError. 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, REST500 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_eventsreuses theSilentExecutorfrom the #1345 test.I also checked it over HTTP with a silent executor behind
create_jsonrpc_routesandcreate_rest_routes: before, both streaming endpoints returned an empty200stream; after, JSON-RPC returns the-32006error and REST returns500with reasonINVALID_AGENT_RESPONSE.ruff check,ruff formatandty checkpass on the changed files.This change was written with Claude Code.
CONTRIBUTINGGuide.bash scripts/format.shfrom the repository root to format)Fixes #1459 🦕
🤖 Generated with Claude Code