[Bug]: message/send hangs forever when the AgentExecutor returns without producing events
維護者通常 2 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
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
- 主要語言
- Python
- 星號
- 2.2k
- 分支
- 528
- 平均合併
- 3 天 9 小時
- 30 天內合併 PR
- 56
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
a2aproject/a2a-python 的其他 Issue
-
[Bug]: `A2A-Version` validation ignores minor versions and the query parameter可能已有人在做 @rohityan 於 68 天前認領。 未關閉component: server status:awaiting response
難度 2/5 1-3 小時 新手友好度 75/100
a2aproject/a2a-python#1204 · 3 則留言 · 已指派 1 人 ·
維護者通常 2 天內回覆
-
[Bug]: REST task/request id sanitization可能已有人在做 @Linux2010 於 126 天前認領。 未關閉maintainers-only
難度 2/5 1-3 小時 新手友好度 65/100
a2aproject/a2a-python#805 · 1 則留言 ·
維護者通常 2 天內回覆
-
[Feat] Major list可能已有人在做 @mykytanetipa 於 4 天前認領。 未關閉maintainers-only
a2aproject/a2a-python#1398 · 1 個 reaction · 已指派 2 人 ·
維護者通常 2 天內回覆
-
[Bug]: REST tenant routes are mounted before `path_prefix`, so tenant requests from the SDK client get 404可能已有人在做 @Revinand 於 5 天前認領。 未關閉component: server status:awaiting response
a2aproject/a2a-python#1376 · 1 則留言 · 已指派 1 人 ·
維護者通常 2 天內回覆
-
DefaultRequestHandler (v2) ignores queue_manager, so the per-task event queue bound (1,024) cannot be configured可能已有人在做 @mykytanetipa 於 13 天前認領。 未關閉component: server status: needs review
a2aproject/a2a-python#1339 · 2 則留言 · 已指派 1 人 ·
維護者通常 2 天內回覆
查看 a2aproject/a2a-python 的全部 Issue
相似的 Issue
-
breaking change
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
check-skill-pages: show fixture build errors when a build fails可能已有人在做 @ShahadatTest 今天認領。 未關閉good first issue P2
難度 1/5 1 小時以內 新手友好度 85/100
coco-research/coco#439 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
esphome/home-assistant-addon#274 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
endurain-project/endurain#882 ·
維護者通常 1 天內回覆
-
good first issue
難度 2/5 1-3 小時 新手友好度 72/100