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

Aperta
#1,459 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@rohityan ci sta già lavorando.

Dal 12/11/2026.

  • #1460 di @1AbdullahButt — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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
Lingua principale
Python
Stelle
2.2k
Fork
540
Merge medio
2g 9h
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di a2aproject/a2a-python

Tutte le issue di a2aproject/a2a-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.