Skip to content

Python: fix(devui): omit connection-specific keep-alive header from SSE streaming responses - #10112

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
hardikkaurani:fix/devui-sse-omit-connection-keep-alive
Nov 9, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
hardikkaurani:fix/devui-sse-omit-connection-keep-alive

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Motivation & Context

In agent_framework_devui._server, streaming Server-Sent Events (SSE) responses explicitly set "Connection": "keep-alive".

According to RFC 9113 section 8.2.2 (HTTP/2) and RFC 9114 (HTTP/3), connection-specific header fields such as Connection are prohibited. Reverse proxies, gateways, and HTTP/2 clients handling DevUI traffic either strip the header or treat the response as malformed (stream error / 502 Bad Gateway). In HTTP/1.1, persistent connections are the default, and transport-level connection headers are managed by the underlying ASGI server (e.g., Uvicorn).

Omitted connection-specific headers resolve this issue while preserving Cache-Control: no-cache and X-Response-ID.

Description & Review Guide

  • What are the major changes?
    • Removed "Connection": "keep-alive" from the StreamingResponse headers in both the OpenAI proxy mode streaming handler and the local executor streaming handler in python/packages/devui/agent_framework_devui/_server.py.
    • Added unit regression tests in python/packages/devui/tests/devui/test_server.py verifying that both streaming endpoints omit connection-specific headers while maintaining Cache-Control: no-cache and X-Response-ID.
  • What is the impact of these changes?
    • DevUI streaming responses comply with RFC 9113 §8.2.2 when deployed behind HTTP/2 or HTTP/3 gateways and reverse proxies.
    • No breaking changes or regressions to HTTP/1.1 client behavior.
  • What do you want reviewers to focus on?
    • Verified that omitting the connection header does not impact SSE event delivery or client disconnection handling.

Related Issue

Fixes #10111

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:
AI assisted with identifying RFC specifications, generating test scaffolding, and drafting documentation. All code and test changes were manually reviewed and verified locally.

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.

…SE streaming responses

Remove the Connection: keep-alive header from both DevUI SSE streaming
responses in _server.py. RFC 9113 section 8.2.2 forbids connection-specific
header fields in HTTP/2 and HTTP/3, and HTTP/1.1 connections remain
persistent by default. Gateway and proxy handlers serving DevUI over HTTP/2
will no longer reject or strip malformed connection headers.

Signed-off-by: Hardik Kaurani <hardikkaurani1@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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hardikkaurani

Hardik K (hardikkaurani) commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi Eduard van Valkenburg (@eavanvalkenburg),

I've opened this PR to address #10111.

DevUI streaming responses were explicitly returning Connection: keep-alive, which violates RFC 9113 §8.2.2 when DevUI is deployed behind reverse proxies or gateways operating over HTTP/2 or HTTP/3.

This PR removes the connection-specific header while preserving Cache-Control: no-cache and X-Response-ID, allowing the underlying ASGI server to handle transport-level connection semantics.

Regression tests covering both local and OpenAI proxy streaming responses have been added and verified locally.

Whenever you have a moment, please feel free to review. Thank you!

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 5, 2026
…tion header in streaming responses

Add regression tests in test_server.py ensuring both the local executor and OpenAI proxy streaming responses omit the connection-specific Connection header while preserving Cache-Control and X-Response-ID.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…d tag test

test_registered_child_tag_does_not_hijack_message_payload registered custom TextState with type_id=text into the global _STATE_TYPE_REGISTRY without cleaning it up. When run in the same test process before session deserialization tests that encounter text Content mappings, the lingering registration caused deserialization failures. Clean up the registered state type in a finally block.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Eduard van Valkenburg (@eavanvalkenburg),

I've pushed an update addressing the failure previously observed in the python-tests-coverage (and downstream merge-gatekeeper) CI job:

  • Root Cause: In packages/core/tests/core/test_sessions.py, test_registered_child_tag_does_not_hijack_message_payload registered a test-scoped TextState with type_id="text" into the module-level _STATE_TYPE_REGISTRY without restoring state upon completion. When executed in the same worker process prior to session deserialization tests (e.g. test_mixed_declaration_only_batch_defers_siblings_until_all_host_results), deserialization of unencapsulated Content items with type="text" invoked the lingering TextState decoder, triggering a KeyError: 'value' / ValueError.
  • Fix: Wrapped the test execution in a try...finally block ensuring "text" and TextState are cleanly popped from _STATE_TYPE_REGISTRY and _STATE_CLASS_REGISTRY.
  • Verification: Verified locally that running test_sessions.py followed by test_function_invocation_logic.py passes without interference, and confirmed both Ruff formatting/linting and Pyright type checking pass with 0 errors.

Whenever you have a moment, could you please approve the workflow run for the updated branch? Thank you!

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Thanks Eduard van Valkenburg (@eavanvalkenburg) for the approval !

Merged via the queue into microsoft:main with commit 9035699 Nov 9, 2026
54 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 6ac875d3 Deployed Nov 7, 2026 by hardikkaurani via add_label #27342
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]: DevUI SSE responses send a connection-specific "Connection: keep-alive" header

3 participants