Skip to content

Python: Accept SSE data lines without a space in the AG-UI client - #10249

Open
ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:python-agui-sse-no-space
Open

ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:python-agui-sse-no-space

Conversation

@nniiovoo

Copy link
Copy Markdown
Contributor

Motivation & Context

AGUIHttpService only parsed SSE lines starting with data: . The space after data: is optional in SSE, so a server that writes data:{...} gave an empty response with no error. Repro is in #10248.

Description & Review Guide

  • What are the major changes? post_run now matches data: and removes one leading space if there is one, as the SSE spec says.
  • What is the impact of these changes? Events from servers that omit the space are no longer dropped. Streams that use data: are parsed the same as before.
  • What do you want reviewers to focus on? I kept it to the prefix check. Multi-line data: events are still not joined, same as before.

Tests: I added a test that streams data:{...} lines through httpx.MockTransport (it fails on main).

Related Issue

Fixes #10248

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: issue analysis, implementation, tests, and this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Signed-off-by: NNIIOVO <haimingni44@gmail.com>

Copilot AI 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.

🟢 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.MockTransport for 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

This branch was successfully deployed

1 active deployment
github-app-auth — 7845fef0 Deployed Nov 10, 2026 by nniiovoo via team_check #9230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: AG-UI client skips SSE events written as "data:" with no space

2 participants