[Bug]: Client hangs when implementing AgentExecutor and awaiting twice in execute method
meoow113 opened this issue · 1 comments
What happened?
A bug happened!
When implementing the AgentExecutor and calling await twice on the complete method within the execute method, the client consumption gets stuck. The queue does not return the second complete result to the client.
Specifically, the issue occurs in the demo_agent_executor.py file where the execute() method is called twice using await:
async def execute(
self,
context: RequestContext,
event_queue: EventQueue,
) -> None:
await updater.add_artifact(
[Part(root=TextPart("hello! "))],
name='conversion_result',
)
await updater.complete()
await updater.complete()
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
I met the same issue: after the server updating the input_required status and then updating the complete status, the client keeps waiting indefinitely.
task1 = Task( status=TaskStatus(state=TaskState.working), id="hello1", contextId="111111111111", kind="task", ) task2 = Task(status=TaskStatus(state=TaskState.input_required), id="hello2", contextId="22222222222", kind="task",) task3 = Task(status=TaskStatus(state=TaskState.completed), id="hello2", contextId="3333333333333", kind="task",)
when call a2a.server.request_handlers.default_request_handler.DefaultRequestHandler._run_event_stream(), it will call agent_executor.execute() first,then queue.close(),here call queue.close() the first time,and the queue come to asyncio.queues.Queue.join() wait for shutdown。
but when call a2a.server.events.event_consumer.EventConsumer.consume_all(),will call queue.close() twice。if the server updating the input_required status and then updating the complete status,consume_all() only yield input_required event ,the complete event will never comsume,. it cause the Queue.join() will always blocked.
I think the it should either restrict simultaneous setting of these two statuses or others, or clear all elements in the queue before closing it.