Skip to content

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

Closed

Description

@1AbdullahButt

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 (

if result is None:
if not active_task.task_created:
# A silent executor means get_task() would block forever.
raise InvalidAgentResponseError(
message='Agent execution produced no events'
)
); on_message_send_stream returns once subscribe() ends, whatever it yielded (
async def on_message_send_stream( # noqa: D102
self,
params: SendMessageRequest,
context: ServerCallContext,
) -> AsyncGenerator[Event, None]:
active_task, request_context = await self._setup_active_task(
params, context
)
task_id = cast('str', request_context.task_id)
async for event in active_task.subscribe(
request=request_context,
include_initial_task=False,
):
# Do NOT break here as we rely on AgentExecutor to yield control.
# ActiveTask consumer (see active_task.py) validates the event
# stream and raises InvalidAgentResponseError on misbehaving agents:
# - an event after a Message
# - Message after entering task mode
# - an event after a terminal state
if isinstance(event, Task):
self._validate_task_id_match(task_id, event.id)
yield apply_history_length(event, params.configuration)
else:
yield event
).

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

Activity

  1. added theissue type on Nov 16, 2026
  2. added
    component: serverIssues related to frameworks for agent execution, HTTP/event handling, database persistence logic.
    on Nov 16, 2026
  3. rohityan commented on Nov 16, 2026

    @rohityan

    Hi @1AbdullahButt , Thanks for the clear report, reproducer, and opening #1460

    I was able to reproduce the error. Unlike DefaultRequestHandlerV2.on_message_send(), DefaultRequestHandlerV2.on_message_send_stream() finishes normally when active_task.subscribe() ends with zero events, causing SendStreamingMessage / POST /message:stream to close with an empty 200 stream instead of raising InvalidAgentResponseError('Agent execution produced no events').

    Your PR #1460 is the right approach in fixing the issue. Assigning the issue to you until the PR is reviewed as a workaround, callers can avoid empty 200 streams by ensuring AgentExecutor.execute() always enqueues at least one Task or Message (or raises an exception) before returning.

  4. added a commit that references this issue on Nov 16, 2026
    c16cab1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

component: serverIssues related to frameworks for agent execution, HTTP/event handling, database persistence logic.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions