-
Notifications
You must be signed in to change notification settings - Fork 303
Description
What happened?
Currently, with the default DefaultRequestHandler implementation, if a client that sent a message/stream request cancels the request or unexpectedly loses connection, the agent's execution is cancelled.
I've confirmed this behavior using the following steps:
-
Modified
a2a-samples/samples/python/agents/helloworldto includeawait asyncio.sleep(1)to simulate a slightly longer agent execution time. -
Started the A2A server.
-
Sent a
message/streamrequest usingcurland immediately cancelled it.curl -X POST \ -i -s \ --header "Content-Type: application/json" \ --data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"message/stream\",\"params\":{\"message\":{\"role\":\"user\",\"parts\":[{\"kind\":\"text\",\"text\":\"テストメッセージ\"}],\"messageId\":\"some-id\"}}}" \ http://localhost:9999/
The server displayed the following error:
asyncio.exceptions.CancelledError: Cancelled by cancel scope 1074c75d0
Considering the existence of the tasks/resubscribe RPC method, it seems unintended for agent execution to be cancelled due to a disconnection mid-request. I've confirmed that this behavior does not occur with message/send requests.
Environment
❯ uv run python --version
Python 3.11.13
a2a-sample commit hash: 3ac8e0b44446edede8f7ea398d48c758285f9eeb
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct