Skip to content

fix(client): dispatch CR-terminated SSE events immediately - #1495

Open
Elon-Jiang wants to merge 1 commit into
a2aproject:mainfrom
Elon-Jiang:fix/sse-cr-immediate-dispatch
Open

Elon-Jiang wants to merge 1 commit into
a2aproject:mainfrom
Elon-Jiang:fix/sse-cr-immediate-dispatch

Conversation

@Elon-Jiang

Copy link
Copy Markdown
Contributor

Description

JsonRpcTransport.send_message_streaming() waits for another chunk when a complete SSE event ends in \r\r and the peer keeps the response open. _aiter_sse_lines held the last CR to recognize a split CRLF. Dispatch the CR immediately and skip only its optional following LF, as the SSE rules require. Buffering unfinished line pieces stays linear.

The new client regression uses a real HTTPX client, request serialization, SSE parser and protobuf result decoding. Its response fixture yields one JSON-RPC event and then waits indefinitely. On unchanged main, CR times out while LF and CRLF return immediately (1 failed, 7 framing controls passed); all cases return with this change. Split CRLF and multi-line CR controls protect against introducing an extra blank line. Only the remote HTTP response is replaced; no hosted Agent was tested.

Validation on Python 3.12:

  • ./scripts/lint.sh: passed (existing non-fatal ty diagnostics).
  • Related HTTP helper and JSON-RPC client tests: 71 passed with HTTPX; 71 passed with HTTPX2 2.16.0.
  • uv run pytest: 2,626 passed, 215 skipped, 4 xfailed, 1 xpassed, and 4 setup errors in cross-version server startup. The exact baseline in an independent environment has the same four setup errors, with 2,621 passed and identical skip/xfail/xpass counts. No test assertion failures in either run. The full suite is therefore not claimed green. PostgreSQL/MySQL integrations were skipped without their DSNs.
  • uv run pytest --cov=src --cov-report=term-missing: same four setup errors, total coverage 94% (repository threshold 88%).

#1489 changes UTF-8 decoding and #1259 concerns BOM handling; neither covers this dispatch delay. This change preserves decoding behavior and does not incorporate those separate fixes.

  • Follow the CONTRIBUTING guide.
  • Conventional commit title.
  • Full tests and linter pass — lint and focused tests pass; full-suite setup limitation detailed above.
  • No documentation changes needed for this framing correction.

Fixes #1494

Prepared and validated with an AI coding assistant.

@Elon-Jiang
Elon-Jiang requested a review from a team as a code owner November 18, 2026 10:20
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/client/transports/http_helpers.py 93.51% 91.14% 🔴 -2.37%
Total 93.62% 93.59% 🔴 -0.04%

Generated by coverage-comment.yml

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CR-terminated SSE events wait for another chunk before delivery

1 participant