You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Session aborts with InvalidProviderOutput when SSE streams mix LF and CRLF line endings #54102
Root cause looks like Effect's SSE parser (pinned at [email protected]) mishandling a stream that mixes line terminators. The provider emits LF-terminated data: {...}\n\n events but CRLF-terminated keepalives : ping - <ts>\r\n\r\n. After a \r\n\r\n blank line the parser drops/merges the following events, so a frame arrives whose data is not valid JSON and the session fails ("Failed to drain Session").
Upstream Effect main appears to already fix this: the parser moved to packages/effect/src/encoding/Sse.ts, the inner scan starts at position + startingPosition, and discardTrailingNewline is parser state instead of a per-feed local.
Request: bump the pinned effect catalog version (root package.json -> 4.0.0-rc.112) to a release that includes the fix, and adjust packages/ai/src/route/framing.ts for the new feed signature (it now returns SseError | undefined).
Plugins
none
OpenCode version
v2.0.26
Steps to reproduce
Configure an OpenAI-compatible provider whose gateway mixes LF-terminated data events (data: {...}\n\n) with CRLF-terminated keepalives (: ping - <ts>\r\n\r\n).
Start a session with a long streamed tool-call / response.
It aborts intermittently with the error above.
Minimal parser-level repro against the pinned parser (effect/unstable/encoding/Sse):
Thanks for the detailed report and the parser-level repro, which made this quick to confirm.
I reproduced it on v2.0.26. I streamed an OpenAI-compatible chat response through OpenCode's SSE framing, with LF-terminated data: events and a CRLF-terminated : ping - N keepalive after each one. When the body arrives whole or in larger chunks (512 or 1024 bytes), events after the CRLF keepalives are lost, and the request fails with OpenAI Chat stream ended without finish_reason. That is the same root cause as your InvalidProviderOutput error. Your makeParser cases also fail the same way with [email protected].
On the latest v2 branch (2f3ba04a), the same test passes in every chunking. That branch has already moved to [email protected] (#50231), whose SSE parser handles mixed line endings, and framing.ts already uses the new effect/encoding/Sse module. So this is likely already fixed, and the fix should be in the next release (it is not in 2.0.26).
The bot will close this issue in 1 day unless you reply that it still happens, for example on a newer version.
Closing this as completed, since we haven't heard back. I reproduced the mixed LF/CRLF problem on v2.0.26: events after the CRLF : ping keepalives were lost and the request failed. On the latest v2 branch (2f3ba04a) every case worked, because that branch moved to [email protected] (#50231). The fix should be in the next release.
If it still happens once you're on a newer version, please comment here or open a new issue and mention this one. Thanks again for the detailed report and the parser repro!
Activity
opencode-agent commentedon Oct 9, 2026
Thanks for the detailed report and the parser-level repro, which made this quick to confirm.
I reproduced it on v2.0.26. I streamed an OpenAI-compatible chat response through OpenCode's SSE framing, with LF-terminated
data:events and a CRLF-terminated: ping - Nkeepalive after each one. When the body arrives whole or in larger chunks (512 or 1024 bytes), events after the CRLF keepalives are lost, and the request fails withOpenAI Chat stream ended without finish_reason. That is the same root cause as yourInvalidProviderOutputerror. YourmakeParsercases also fail the same way with[email protected].On the latest
v2branch (2f3ba04a), the same test passes in every chunking. That branch has already moved to[email protected](#50231), whose SSE parser handles mixed line endings, andframing.tsalready uses the neweffect/encoding/Ssemodule. So this is likely already fixed, and the fix should be in the next release (it is not in 2.0.26).The bot will close this issue in 1 day unless you reply that it still happens, for example on a newer version.
rekram1-node commentedon Oct 9, 2026
1aae67e
fixed in next release
opencode-agent commentedon Oct 10, 2026
Closing this as completed, since we haven't heard back. I reproduced the mixed LF/CRLF problem on v2.0.26: events after the CRLF
: pingkeepalives were lost and the request failed. On the latestv2branch (2f3ba04a) every case worked, because that branch moved to[email protected](#50231). The fix should be in the next release.If it still happens once you're on a newer version, please comment here or open a new issue and mention this one. Thanks again for the detailed report and the parser repro!