refactor(http): eliminate third-party httpx-sse dependency#1132
refactor(http): eliminate third-party httpx-sse dependency#1132Iwaniukooo11 wants to merge 5 commits into
Conversation
Replaced httpx-sse imports with a native Server-Sent Events (SSE) streaming parser in the client transport helpers. Refactored transport unit tests to mock standard HTTP response line streaming. Removed the httpx-sse dependency from pyproject.toml and uv.lock.
There was a problem hiding this comment.
Code Review
This pull request removes the external httpx-sse dependency and implements a custom Server-Sent Events (SSE) parser (parse_sse_stream) to process streaming HTTP responses directly. Corresponding test suites have been updated to mock httpx.Response.aiter_lines instead of EventSource. Feedback was provided on a potential bug in the custom parser where buffered event data could be lost if the stream terminates without a trailing empty line, along with a suggestion to handle empty event fields correctly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/client/transports/http_helpers.py | 93.59% | 95.54% | 🟢 +1.95% |
| src/a2a/server/events/event_queue_v2.py | 91.71% | 91.19% | 🔴 -0.52% |
| src/a2a/utils/telemetry.py | 91.47% | 90.70% | 🔴 -0.78% |
| Total | 92.97% | 92.97% | ⚪️ 0.00% |
Generated by coverage-comment.yml
| yield data | ||
|
|
||
|
|
||
| class _SSEEventSource: |
There was a problem hiding this comment.
_SSEEventSource was added in #912 as a workaround for this library. Could you please check if it's still required? Also its comment likely requires update as it mentions aconnect_sse function from the package we remove now.
There was a problem hiding this comment.
Regarding the docstring - You are right that it was outdated, thanks for checking that
Regarding the _SSEEventSource - Dumping httpx_sse doesn't resolve the nested async generators issue (as the core behaviour of send_http_stream_request didn't change), thus current class still handles early break scenario in a proper way, acting as a @contextmanager with properly defined __aexit__ and __aenter__ methods
Summary
Removed the third-party dependency
httpx-sseto reduce the SDK's attack surface. Replaced it with a native, lightweight Server-Sent Events (SSE) streaming parser inside the HTTP transport helpers.Changes
httpx-ssefrompyproject.tomland updateduv.lock.EventSource.aiter_sse()with a localparse_sse_streamgenerator that parses streaming line blocks and yields typed event payloads.test_rest_client.pyandtest_jsonrpc_client.pyto mock standardResponseline streaming instead of the third-partyEventSourceobject.Verification
Ran tests and linters locally with
httpx-sseuninstalled:Status: 72 tests passed, linter green.