Skip to content

fix(http): accept CR line endings in SSE streams - #198

Open
Elon-Jiang wants to merge 1 commit into
agentclientprotocol:mainfrom
Elon-Jiang:fix/http-sse-cr-line-endings
Open

Elon-Jiang wants to merge 1 commit into
agentclientprotocol:mainfrom
Elon-Jiang:fix/http-sse-cr-line-endings

Conversation

@Elon-Jiang

Copy link
Copy Markdown

Summary

The public Streamable HTTP transport never delivers an SSE event delimited by CR while the connection stays open. LF and CRLF controls deliver normally. SSE permits all three line endings (WHATWG).

Normalize CR and CRLF before the existing line parser. Remember a trailing CR across chunks so the following LF is consumed once, without delaying delivery until another chunk or EOF. The regression covers split CRLF, empty chunks, multibyte UTF-8, multiple data fields and mixed endings; U+0085/U+2028 inside JSON stay unchanged.

Related issues

N/A; found through the Streamable HTTP receive path. Existing #183 handles JSON-RPC batches, not CR framing.

Testing

  • Public create_http_stream() → initialize → receive, with the real HTTPX2 client and a controlled long-lived response stream: unchanged main 4 fail / 3 controls pass, fixed 7 pass.
  • Related HTTP client/SSE tests: 36 passed.
  • make check: passed.
  • NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 make test: 547 passed, 1 skipped (optional Gemini), one existing code-generator warning. The initial run had five WebSocket failures because the local environment routed loopback through a SOCKS proxy without its optional dependency; direct loopback passed without source/dependency changes.

Only the external HTTP response is supplied by MockTransport; no live agent/model was used. No schema or public API changes.

AI assistance: Codex prepared the patch and ran the listed checks. No human review is claimed.

Docs & screenshots

No public API or schema changes. This restores existing SSE framing behavior; no new configuration, guide or screenshot is needed.

Checklist

  • Conventional Commit title.
  • Tests cover the change.
  • Docs/examples considered; no API change.
  • No schema regeneration required.

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.

1 participant