Skip to content

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

Description

@nniiovoo

Observed Behavior

AGUIHttpService only reads lines that start with data: (with a space). In SSE the space after data: is optional, and some servers send data:{...}. All of those events are skipped, so AGUIChatClient returns an empty response and no error.

Expected Behavior

Both data: {...} and data:{...} are parsed, as the SSE spec says: one leading space after the colon is removed if present.

Steps to Reproduce

  1. Point AGUIChatClient at a server that writes SSE lines as data:{...}
  2. Call get_response
  3. The response text is empty

Minimal Reproduction

import asyncio
import json

import httpx

from agent_framework_ag_ui import AGUIChatClient

EVENTS = [
    {"type": "RUN_STARTED", "threadId": "t1", "runId": "r1"},
    {"type": "TEXT_MESSAGE_START", "messageId": "m1", "role": "assistant"},
    {"type": "TEXT_MESSAGE_CONTENT", "messageId": "m1", "delta": "Hello from the server"},
    {"type": "TEXT_MESSAGE_END", "messageId": "m1"},
    {"type": "RUN_FINISHED", "threadId": "t1", "runId": "r1"},
]


async def run(prefix: str) -> None:
    def handler(request: httpx.Request) -> httpx.Response:
        body = "".join(f"{prefix}{json.dumps(e)}\n\n" for e in EVENTS)
        return httpx.Response(200, headers={"content-type": "text/event-stream"}, text=body)

    http = httpx.AsyncClient(transport=httpx.MockTransport(handler))
    client = AGUIChatClient(endpoint="http://server/", http_client=http)
    response = await client.get_response("hi")
    print(f"{prefix!r:9} -> {response.text!r}")


asyncio.run(run("data: "))
asyncio.run(run("data:"))

Error Messages and Stack Traces

'data: '  -> 'Hello from the server'
'data:'   -> ''

Package Versions

agent-framework-core 1.25.0, agent-framework-ag-ui 1.8.0 (main at fe87fdd), httpx 0.28.1

Python Version

Python 3.12

Operating System

macOS

Regression

No

Additional Context

The check is line.startswith("data: ") in post_run in _http_service.py. A fix could be to match data: and drop one leading space if there is one. I have a fix with a test and will open a PR.

AI assistance: I used an AI assistant to help find the cause and write this up. I ran the repro myself.

Acknowledgements

  • I searched existing issues and did not find a duplicate.
  • I personally verified this behavior and the reproduction details are authentic.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 10, 2026
  2. added
    ag-uiUsage: [Issues, PRs], Target: AG-UI protocol integration
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Nov 10, 2026
  3. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    Reproduced on main (fe87fdd) using a local httpx MockTransport: data: {...} returns 'Hello from the server', while (redacted) returns ''. The cause is line.startswith("data: ") at httpservice.py line 272 in python/packages/ag-ui/agent_framework_ag_ui`. Routed to the ag-ui owner.

    Support boundary: unclear. The linked SSE spec describes the behavior, but I didn't find an Agent Framework doc or ADR that states it. A maintainer should decide the scope. Fix PR #10249 is open and I haven't verified it.

    Run: https://github.com/microsoft/agent-framework/actions/runs/42881586491

    Generated by Issue Routing for #10248 · copilot · auto · ~19 AIC · ⌖ ~1 AIC · ⊞ 5.2K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ag-uiUsage: [Issues, PRs], Target: AG-UI protocol integrationpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowtriageUsage: [Issues], Target: All issues that still need to be triaged

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions