Repository navigation
Python: Accept SSE data lines without a space in the AG-UI client - #10249
Open
ni (nniiovoo) wants to merge 1 commit into
Open
ni (nniiovoo) wants to merge 1 commit into
ni (nniiovoo) wants to merge 1 commit into
Conversation
Signed-off-by: NNIIOVO <haimingni44@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change supporting SSE events without a space after data:.
No open issues 🎉
What changed in this PR
Fixes #10248 by allowing the Python AG-UI client to parse server-sent events without a space after data:, while preserving support for the existing spaced format.
Changes:
- Matches
data:and removes one leading space when present. - Adds a regression test using
httpx.MockTransportfor streams without the space. - Leaves multi-line event handling unchanged.
| File | Description |
|---|---|
python/packages/ag-ui/tests/ag_ui/test_http_service.py |
Adds regression coverage for data:{...} event streams. |
python/packages/ag-ui/agent_framework_ag_ui/_http_service.py |
Accepts both SSE data-prefix formats. |
Review effort: Balanced
2 tasks done
This branch was successfully deployed
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.
Motivation & Context
AGUIHttpServiceonly parsed SSE lines starting withdata:. The space afterdata:is optional in SSE, so a server that writesdata:{...}gave an empty response with no error. Repro is in #10248.Description & Review Guide
post_runnow matchesdata:and removes one leading space if there is one, as the SSE spec says.data:are parsed the same as before.data:events are still not joined, same as before.Tests: I added a test that streams
data:{...}lines throughhttpx.MockTransport(it fails on main).Related Issue
Fixes #10248
AI Assistance
AI assistance details: issue analysis, implementation, tests, and this description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.