fix(react-headless): robust SSE framing in agUIAdapter#331
Open
boffin-dmytro wants to merge 1 commit intothesysdev:mainfrom
Open
fix(react-headless): robust SSE framing in agUIAdapter#331boffin-dmytro wants to merge 1 commit intothesysdev:mainfrom
boffin-dmytro wants to merge 1 commit intothesysdev:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes
@openuidev/react-headless’s defaultagUIAdapter()handle real-world SSE streams reliably.The previous implementation parsed SSE by splitting each network chunk on
\n, which can drop events when JSON/lines are split across chunks (common in production), and didn’t fully respect SSE framing rules.What changed
agUIAdapter()SSE parsing:\r\n)data:fields (joined with\nper SSE spec)[DONE]as a terminatordata:agUIAdapter()Why it matters
SSE chunk boundaries are arbitrary, and many servers emit CRLF and keepalives. With this change, AG-UI streaming is much more resilient under normal network conditions, preventing silent token/event loss and incomplete assistant messages.
Scope note
This PR intentionally focuses on
agUIAdapter()(the default) to keep the change tight and low-risk. Similar SSE framing improvements could be applied to the OpenAI SSE adapters in a follow-up if maintainers want to consolidate parsing behavior.Files changed
packages/react-headless/src/stream/adapters/ag-ui.tspackages/react-headless/src/store/__tests__/createChatStore.test.tsdocs/content/docs/api-reference/react-headless.mdxKinly review this update.