Repository navigation
Python: Preserve OpenAI Responses SSE error metadata - #9616
Open
ZedingZhang (ZedingZhang) wants to merge 1 commit into
Open
ZedingZhang (ZedingZhang) wants to merge 1 commit into
ZedingZhang (ZedingZhang) wants to merge 1 commit into
Conversation
ZedingZhang (ZedingZhang)
deployed
to
github-app-auth
October 23, 2026 03:52 — with
GitHub Actions
Active
ZedingZhang (ZedingZhang)
deployed
to
github-app-auth
October 23, 2026 03:52 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused change preserves existing exception behavior and covers the affected streaming paths, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Preserves structured metadata from OpenAI Responses SSE error events, addressing #9593 so callers can classify provider errors without parsing exception text.
Changes:
- Adds a private
RuntimeErrorsubclass retaining the original event and itscode,message, andparam, while preserving existing error text and wrapping. - Adds regression coverage for normal, structured-output, and resumed streaming, including continuation-token cleanup and rejection of error events as response updates.
| File | Description |
|---|---|
python/packages/openai/tests/openai/test_openai_chat_client.py |
Tests metadata preservation across streaming paths and error variants. |
python/packages/openai/agent_framework_openai/_chat_client.py |
Retains provider error metadata in the existing exception chain. |
Review effort: Balanced
ZedingZhang (ZedingZhang)
deployed
to
github-app-auth
October 23, 2026 03:56 — with
GitHub Actions
Active
ZedingZhang (ZedingZhang)
deployed
to
github-app-auth
October 23, 2026 04:03 — with
GitHub Actions
Active
ZedingZhang (ZedingZhang)
deployed
to
github-app-auth
October 23, 2026 04:39 — with
GitHub Actions
Active
ZedingZhang (ZedingZhang)
marked this pull request as ready for review
October 23, 2026 04:39
ZedingZhang (ZedingZhang)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 23, 2026 04:39
ZedingZhang (ZedingZhang)
deployed
to
github-app-auth
October 23, 2026 04:39 — with
GitHub Actions
Active
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
Flat Responses API SSE
errorevents currently become text-onlyRuntimeErrorinstances before being wrapped inChatClientException. Applications lose the provider's structured error code, message, and parameter when they unwrap the exception, preventing reliable error classification for bounded retries and telemetry.Description & Review Guide
ResponseErrorEventand itscode,message, andparamon a privateRuntimeErrorsubclass used by the existing error wrapper. Add regression coverage for normal streaming, structured-output streaming, and resumed streaming, includingserver_error,rate_limit_exceeded, absent codes, and populated or absent parameters.ChatClientException.__cause__without parsing exception text. The existing exception message andRuntimeErrorcompatibility are preserved, as is continuation-token cleanup on a failed resumed stream. There are no new public exports or dependencies. The OpenAI package's unit tests, source and test typing checks, formatting, lint, package build, and commit hooks pass locally.The advisory Public API Compatibility check currently crashes with Griffe 2.4.0 while resolving the unchanged base-side
agent_framework._workflows._edge.EdgeGroup.builtin_typealias tobuiltins.type. Comparing the unmodified base commita8e284ca8ce7c2a6b4a4641ef35e131d75a5cda3with itself reproduces the sameAliasResolutionError; the check does not reach this package's comparison. Other substantive fork workflows are awaiting maintainer approval.Related Issue
Fixes #9593
The issue is currently marked
reproduced, without aready-for-implementationlabel or an explicit maintainer approval comment. This PR presents the focused reproduction and fix for maintainer confirmation. No competing open PR referencing this issue was found at submission.AI Assistance
AI assistance details: Codex assisted with issue analysis, implementation, regression tests, and this PR description. The reported regression was reproduced locally, and the final change received separate standards and specification reviews.
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.