Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: message/send hangs forever when the AgentExecutor returns without producing events

Aperta
#1,330 0 commenti 0 reazioni 2 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@Iwaniukooo11 ci sta già lavorando.

Dal 12/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

What happened?

message/send hangs indefinitely when an AgentExecutor returns normally without enqueueing any event. Both handlers are affected:

  • DefaultRequestHandlerV2: no response within 3s (tested; it never returns).
  • DefaultRequestHandler (legacy): no response within 10s (tested; it never returns), even though it contains an if not result: raise InternalError guard at src/a2a/server/request_handlers/default_request_handler.py:456-457 — empirically that line is never reached in this scenario.

Each hanging request pins a client connection plus the handler's internal producer/consumer tasks.

Root cause (V2)

default_request_handler_v2.py:437-439:

if result is None:
    logger.debug('Missing result for task %s', request_context.task_id)
    result = await active_task.get_task()

ActiveTask.get_task() (src/a2a/server/agent_execution/active_task.py:965-967) awaits self._task_created.wait() with no timeout. _task_created is only set when (a) the task already existed at start(), (b) the consumer processes a task event, or (c) the producer fails. A silent success (executor returns, zero events) sets none of them, so the wait never completes.

For the legacy handler, the equivalent raise InternalError guard exists but is unreachable in this scenario — the flow blocks earlier inside consume_and_break_on_interrupt.

Reproduction
Self-contained script (main @ 494a8ec, Python 3.10)
import asyncio

from a2a.auth.user import UnauthenticatedUser
from a2a.server.agent_execution import AgentExecutor
from a2a.server.context import ServerCallContext
from a2a.server.request_handlers import DefaultRequestHandlerV2
from a2a.server.tasks import InMemoryTaskStore
from a2a.types.a2a_pb2 import (
    AgentCapabilities,
    AgentCard,
    Message,
    Part,
    Role,
    SendMessageConfiguration,
    SendMessageRequest,
)


class SilentExecutor(AgentExecutor):
    # Returns normally without producing any event. The AgentExecutor
    # contract only says it *should* enqueue events, so this is a legal
    # (if buggy) implementation.
    async def execute(self, context, event_queue):
        return None

    async def cancel(self, context, event_queue):
        pass


async def main():
    handler = DefaultRequestHandlerV2(
        agent_executor=SilentExecutor(),
        task_store=InMemoryTaskStore(),
        agent_card=AgentCard(
            name='t',
            version='1.0',
            capabilities=AgentCapabilities(streaming=True),
        ),
    )
    params = SendMessageRequest(
        message=Message(
            role=Role.ROLE_USER, message_id='m1', parts=[Part(text='Hi')]
        ),
        configuration=SendMessageConfiguration(
            accepted_output_modes=['text/plain']
        ),
    )
    try:
        await asyncio.wait_for(
            handler.on_message_send(
                params, ServerCallContext(user=UnauthenticatedUser())
            ),
            timeout=3,
        )
        print('returned (no hang)')
    except asyncio.TimeoutError:
        print('HANG CONFIRMED: on_message_send did not return within 3s')


asyncio.run(main())

Observed output:

HANG CONFIRMED: on_message_send did not return within 3s
Expected behavior

message/send should fail fast with an InternalError (as the legacy handler's raise InternalError guard intends) when the agent produces no result at all, instead of hanging forever and leaking the request, producer and consumer tasks.

Suggested fix
  • In DefaultRequestHandlerV2.on_message_send, when result is None and _task_created is not set, raise InternalError instead of awaiting get_task() (aligning with the legacy guard's intent). Alternatively, add a timeout to ActiveTask.get_task().
  • Worth auditing why the legacy handler never reaches its raise InternalError guard in this scenario.

Happy to submit a PR with tests.

Relevant log output
HANG CONFIRMED: on_message_send did not return within 3s
Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
Python
Stelle
2.2k
Fork
511
Merge medio
2g 22h
PR unite (30g)
43

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.