[Bug]: SendStreamingMessage returns an empty 200 stream when the executor produces no events
Maintainers usually reply within 2 days
Assessment
This issue has not been assessed yet.
Description
What happened?
Since #1345, SendMessage with an AgentExecutor that returns without enqueueing any event fails with InvalidAgentResponseError ("Agent execution produced no events", JSON-RPC -32006). SendStreamingMessage with the same executor still answers 200 text/event-stream with zero events and closes, so the client gets no Task, no Message and no error.
Spec §3.1.2 says the stream MUST either contain exactly one Message, or begin with the Task: https://a2a-protocol.org/latest/specification/#312-send-streaming-message. An empty stream is neither, and the client can't tell it apart from a stream that closed early.
Code on main (2ba8e7b): on_message_send has the guard (https://github.com/a2aproject/a2a-python/blob/2ba8e7bd27fce7de92c33813a46dbea1e3f7e6ce/src/a2a/server/request_handlers/default_request_handler_v2.py#L522-L527); on_message_send_stream returns once subscribe() ends, whatever it yielded (https://github.com/a2aproject/a2a-python/blob/2ba8e7bd27fce7de92c33813a46dbea1e3f7e6ce/src/a2a/server/request_handlers/default_request_handler_v2.py#L547-L572).
Repro
import asyncio
from a2a.server.agent_execution import AgentExecutor
from a2a.server.context import ServerCallContext
from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.tasks import InMemoryTaskStore
from a2a.types.a2a_pb2 import AgentCapabilities, AgentCard, Message, Part, Role, SendMessageRequest
class SilentExecutor(AgentExecutor):
async def execute(self, context, event_queue):
return None
async def cancel(self, context, event_queue):
return None
def request():
return SendMessageRequest(message=Message(message_id='m1', role=Role.ROLE_USER, parts=[Part(text='hi')]))
async def main():
handler = DefaultRequestHandler(
agent_executor=SilentExecutor(),
task_store=InMemoryTaskStore(),
agent_card=AgentCard(name='a', version='1', capabilities=AgentCapabilities(streaming=True)),
)
try:
await handler.on_message_send(request(), ServerCallContext())
except Exception as e:
print('on_message_send ->', type(e).__name__, e)
events = [e async for e in handler.on_message_send_stream(request(), ServerCallContext())]
print('on_message_send_stream ->', events)
asyncio.run(main())
Output on main:
on_message_send -> InvalidAgentResponseError Agent execution produced no events
on_message_send_stream -> []
Over HTTP the same thing shows up as SendMessage returning a -32006 error, while SendStreamingMessage (JSON-RPC) and POST /message:stream (REST) return 200 with an empty event stream.
Expected: the streaming call fails the same way as the non-streaming one: InvalidAgentResponseError, which the JSON-RPC dispatcher and the REST dispatcher already turn into an error response because they read the first event eagerly.
Actual: an empty, successful stream.
I have a fix with a regression test and will open a PR.
Code of Conduct
- I agree to follow this project's Code of Conduct
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 540
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 56
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from a2aproject/a2a-python
-
[Bug]: `A2A-Version` validation ignores minor versions and the query parameterPossibly taken @rohityan claimed this 82 days ago. Opencomponent: server status:awaiting response status:stale
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
a2aproject/a2a-python#1204 · 4 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
[Bug]: REST task/request id sanitizationMay be free again A pull request for this issue was closed without being merged. Openmaintainers-only
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a2aproject/a2a-python#805 · 1 comment ·
Maintainers usually reply within 2 days
-
[Bug]: JSON-RPC client ignores the JSON-RPC error body when the HTTP status is not 2xxPossibly taken @rohityan claimed this today. Open
a2aproject/a2a-python#1475 · 2 assignees ·
Maintainers usually reply within 2 days
-
[Feat]: validate_input_modes: match media ranges such as image/* declared in the agent cardPossibly taken @rohityan claimed this 2 days ago. Open
a2aproject/a2a-python#1468 · 2 assignees ·
Maintainers usually reply within 2 days
-
Required extensions aren't enforced, so ExtensionSupportRequiredError is never raisedPossibly taken @rohityan claimed this 2 days ago. Opencomponent: server status:awaiting response
a2aproject/a2a-python#1467 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
All issues in a2aproject/a2a-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Install the skills as a Claude Code pluginPossibly taken @ruban-24 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
FAIRmat-NFDI/pynxtools#874 ·
-
Eval: PublicationOpendata
Difficulty 2/5 1-3 hours Newbie friendliness 66/100