[Bug]: message/send hangs forever when the AgentExecutor returns without producing events
Mantenedores costumam responder em até 2 dias
Avaliação
Esta issue ainda não foi avaliada.
Descrição
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 anif not result: raise InternalErrorguard atsrc/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, whenresult is Noneand_task_createdis not set, raiseInternalErrorinstead of awaitingget_task()(aligning with the legacy guard's intent). Alternatively, add a timeout toActiveTask.get_task(). - Worth auditing why the legacy handler never reaches its
raise InternalErrorguard 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
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 518
- Merge médio
- 3d 7h
- PRs com merge (30d)
- 38
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de a2aproject/a2a-python
-
[Bug]: `A2A-Version` validation ignores minor versions and the query parameterTalvez já em andamento @rohityan assumiu há 62 dias. Abertacomponent: server status:awaiting response
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
a2aproject/a2a-python#1204 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 2 dias
-
[Bug]: REST task/request id sanitizationTalvez já em andamento @Linux2010 assumiu há 121 dias. Abertamaintainers-only
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
a2aproject/a2a-python#805 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
v0.3 REST GetTask returns 500 for a non-integer historyLengthTalvez já em andamento @rohityan assumiu há 1 dia. Aberta
a2aproject/a2a-python#1381 · 2 responsáveis ·
Mantenedores costumam responder em até 2 dias
-
v0.3 pushNotificationConfig/get by task id fails with Validation failedTalvez já em andamento @rohityan assumiu há 1 dia. Aberta
a2aproject/a2a-python#1379 · 2 responsáveis ·
Mantenedores costumam responder em até 2 dias
-
[Bug]: REST tenant routes are mounted before `path_prefix`, so tenant requests from the SDK client get 404Talvez já em andamento @rohityan assumiu há 1 dia. Aberta
a2aproject/a2a-python#1376 · 2 responsáveis ·
Mantenedores costumam responder em até 2 dias
Todas as issues de a2aproject/a2a-python
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
scikit-learn-contrib/category_encoders#553 ·
Mantenedores costumam responder em até 1 dia
-
tests/strategies_test.py:174 goes uncovered on about 1 run in 100, failing the coverage ratchetAbertaflaky-watch
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
btclib-org/btclib#2839 ·
Mantenedores costumam responder em até 1 dia
-
BarrelList constructor drops false-valued iterable contentsTalvez já em andamento @Gambit-Checkmate assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 19 dias
-
[Performance]: Redundant object-storage pull when model and tokenizer share the same RunAI URIAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
vllm-project/vllm#63863 ·
Mantenedores costumam responder em até 1 dia