Skip to content

[Bug]: JSON-RPC streaming endpoints hard‑close when send() blocks longer than Starlette’s default timeout #545

@ConnorDoyle

Description

@ConnorDoyle

What happened?

Current behavior

JSONRPCApplication always builds EventSourceResponse with Starlette’s defaults (src/a2a/server/apps/jsonrpc/jsonrpc_app.py:323). When an agent pauses longer than the default send_timeout, the next write raises SendTimeoutError, the response task exits, and the client never receives the remaining events. Long-lived agents tasks hit this path while waiting on external work.

Expected/desired behavior

Developers using the SDK should be able to configure a larger timeout or disable it entirely without subclassing the server. Semi-idle agents should keep their SSE channel open, even if send() occasionally blocks longer than five seconds.

Proposed fix

  1. Add a stream_send_timeout: float | None option on JSONRPCApplication (plumbed through A2AStarletteApplication/A2AFastAPIApplication) and pass it to EventSourceResponse(...). Preserve the current default when the option is omitted.
  2. Allow per-request overrides via ServerCallContext.state["stream_send_timeout"] so specific handlers can raise/lower the ceiling.
  3. Document the new control (and the failure mode) in the SDK guide, recommending that long-running agents either disable or adjust the timeout, or emit frequent heartbeat events.

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions