Is your feature request related to a problem? Please describe.
A2A SDK v1 creates sse-starlette EventSourceResponse instances for JSON-RPC and REST streaming endpoints, but there is currently no supported way to pass shutdown_grace_period.
Because sse-starlette defaults this value to 0, an in-progress SSE response is cancelled immediately when the server receives SIGTERM. This can prevent a finite message/stream request from delivering its remaining events and terminal event, even when the ASGI server is configured to wait for in-flight requests during graceful shutdown.
Relevant response creation sites include:
src/a2a/server/routes/jsonrpc_dispatcher.py
src/a2a/server/routes/rest_dispatcher.py
Describe the solution you'd like
Please provide a supported way to configure shutdown_grace_period and pass it to every EventSourceResponse created by the A2A HTTP server.
For example, this could be exposed through create_jsonrpc_routes() and create_rest_routes(), through their dispatchers, or through a general EventSourceResponse options/factory parameter.
The existing default of 0 could be preserved for backward compatibility:
routes = create_jsonrpc_routes(
request_handler,
rpc_url="/",
shutdown_grace_period=30.0,
)
With this configuration, a finite A2A stream should be allowed to finish naturally within the grace period before being force-cancelled.
Describe alternatives you've considered
- Subclassing or replacing the A2A dispatchers solely to customize
EventSourceResponse.
- Monkey-patching
EventSourceResponse.
- Globally disabling
sse-starlette automatic graceful drain and relying on the ASGI server timeout. This may cause indefinite streams to block shutdown and is too broad for this use case.
Additional context
This is separate from #545. That issue concerned send_timeout and was marked obsolete for the v1 implementation; this request concerns cooperative shutdown after SIGTERM.
sse-starlette already supports shutdown_grace_period,
https://github.com/sysid/sse-starlette#cooperative-shutdown
so the missing piece is a configuration path from the A2A SDK API to EventSourceResponse.
The configured value should be documented as being shorter than the ASGI server's graceful-shutdown timeout.
Code of Conduct
Is your feature request related to a problem? Please describe.
A2A SDK v1 creates
sse-starletteEventSourceResponseinstances for JSON-RPC and REST streaming endpoints, but there is currently no supported way to passshutdown_grace_period.Because
sse-starlettedefaults this value to0, an in-progress SSE response is cancelled immediately when the server receives SIGTERM. This can prevent a finitemessage/streamrequest from delivering its remaining events and terminal event, even when the ASGI server is configured to wait for in-flight requests during graceful shutdown.Relevant response creation sites include:
src/a2a/server/routes/jsonrpc_dispatcher.pysrc/a2a/server/routes/rest_dispatcher.pyDescribe the solution you'd like
Please provide a supported way to configure
shutdown_grace_periodand pass it to everyEventSourceResponsecreated by the A2A HTTP server.For example, this could be exposed through
create_jsonrpc_routes()andcreate_rest_routes(), through their dispatchers, or through a generalEventSourceResponseoptions/factory parameter.The existing default of
0could be preserved for backward compatibility:With this configuration, a finite A2A stream should be allowed to finish naturally within the grace period before being force-cancelled.
Describe alternatives you've considered
EventSourceResponse.EventSourceResponse.sse-starletteautomatic graceful drain and relying on the ASGI server timeout. This may cause indefinite streams to block shutdown and is too broad for this use case.Additional context
This is separate from #545. That issue concerned
send_timeoutand was marked obsolete for the v1 implementation; this request concerns cooperative shutdown after SIGTERM.sse-starlettealready supportsshutdown_grace_period,https://github.com/sysid/sse-starlette#cooperative-shutdown
so the missing piece is a configuration path from the A2A SDK API to
EventSourceResponse.The configured value should be documented as being shorter than the ASGI server's graceful-shutdown timeout.
Code of Conduct