Read model event streams with every SSE line ending by Maya-Kid · Pull Request #1050 · deeplethe/utopia · GitHub
Skip to content

Read model event streams with every SSE line ending - #1050

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:codex/llm-sse-line-endings
Oct 2, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
Maya-Kid:codex/llm-sse-line-endings

Conversation

@Maya-Kid

@Maya-Kid Maya-Kid commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

An OpenAI-compatible endpoint using CRLF could send a valid answer that the raw and tool readers reported as Interrupted with zero characters; a bare-CR stream also failed in the collected reader. All three readers looked only for LF/LF frame boundaries.

Normalize the SSE line endings in a shared byte buffer before framing. It remembers a CR across network chunks, preserves split UTF-8, and keeps the existing completion and interruption semantics. No dependency or public API changes.

Validation:

  • All three reader regressions failed before the fix; the 47 LLM tests now pass.
  • Covers LF, CRLF, CR, mixed endings, every byte split, tool arguments, finish reason, usage, and interrupted character counts. A gated HTTP test verifies raw/tool deltas arrive before the connection closes.
  • cargo +1.98.1 fmt --all --check, workspace clippy with -D warnings, workspace tests with PostgreSQL 16/pgvector and required DB/PDF guards, and workspace build pass.
  • Web tests, typecheck, style guard, and production build pass on the unchanged web baseline.

Signed-off-by: dada-yan <BinjunYann@gmail.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Maya-Kid. Read the buffer and the three call sites. One shared SseBuffer that normalises CRLF and bare CR before framing, remembers a CR across chunks and keeps bytes until a frame is whole is the right shape, and the every-byte-split test pins it. The 47 tests pass here. Landing it.

@WaylandYang
WaylandYang merged commit e56db79 into deeplethe:dev Oct 2, 2026
6 checks passed
@WaylandYang WaylandYang mentioned this pull request Oct 2, 2026
@Maya-Kid
Maya-Kid deleted the codex/llm-sse-line-endings branch October 15, 2026 03:29
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.

2 participants