Skip to content

[Bug]: SSE client drops the last event when the stream ends without a blank line #1213

Description

@anxkhn

What happened?

parse_sse_stream in src/a2a/client/transports/http_helpers.py only yields an event when it sees a blank line. If the peer closes the connection after data: {...} with no trailing blank line, leftover payload_chunks are thrown away.

WHATWG SSE says a pending event must be dispatched when the connection closes. JsonRpcTransport and RestTransport both use this parser, so a completed Task/Message can vanish and the client sits there as if the stream is still open.

Repro

  1. Feed parse_sse_stream a response whose last lines are data: {"task":{...}} with no following empty line.
  2. Exhaust the generator.

Observed: zero events.
Expected: one ("message", "{...}") event.

Existing tests always send a trailing \n, so this path is untested.

Relevant log output

n/a. Unit-reproducible in tests/client/transports/test_http_helpers.py.

Code of Conduct

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

Metadata

Metadata

Assignees

Labels

component: clientIssues related to transport logic and configuration for external apps connecting to A2A agents.status:awaiting response

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions