Skip to content

fix(responses): preserve terminal errors through stream cleanup - #5187

Merged
jbeckwith-oai merged 1 commit into
mainfrom
codex/fix-responses-terminal-errors
Sep 27, 2026
Merged

jbeckwith-oai merged 1 commit into
mainfrom
codex/fix-responses-terminal-errors

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Collaborator

Summary

This pull request fixes Responses streaming errors being masked by transport teardown failures. After yielding a provider failure event, the model now closes the stream explicitly and raises the saved ModelBehaviorError, preserving the provider's diagnostics. It also recognizes error as terminal in the request-ID stream wrapper.

Adding error to the wrapper alone fixes cleanup-callback failures but leaves real HTTP teardown failures exposed during iteration. The regression tests exercise both boundaries with synthetic payloads and the real OpenAI client, while retaining pre-terminal transport failures and the successful-terminal control.

Test plan

  • Confirmed the callback-error case and real HTTP error/response.failed/response.incomplete cases fail before the fix.
  • Responses model tests: 192 passed, including cleanup and cancellation coverage.
  • Independent code review: no actionable findings; 11 focused checks passed.
  • Full repository verification: formatting, lint, mypy, pyright, and parallel/serial test suites passed. Native macOS sandbox tests are delegated to the dedicated CI job per repository policy.

Issue number

Fixes #5181

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • I've completed an independent code review before submitting this PR

@jbeckwith-oai
jbeckwith-oai requested review from a team, rm-openai and seratch as code owners September 27, 2026 16:45
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T16:47:21.540217Z 36d3776 PR opened
🔒 Security Review ✅ Completed 2026-09-27T16:49:06.742933Z 36d3776 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@markstuart-oai markstuart-oai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 36d3776ff54c0fde32ad77059170f9f08074f51a. Stopping iteration after the failure event keeps transport teardown from replacing the saved provider error, while the existing finally path still closes the stream. Recognizing error as terminal also covers the wrapper cleanup path. The regressions distinguish context cleanup from HTTP/SSE teardown, preserve provider diagnostics and event delivery, and retain the pre-terminal close-failure control. No blocking findings.

Verified all 22 hosted checks passed on this commit. Source review only here; I did not execute the reported local suites or live-provider tests.

@jbeckwith-oai
jbeckwith-oai merged commit 2b0361d into main Sep 27, 2026
22 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/fix-responses-terminal-errors branch September 27, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Responses streaming: the error event is not treated as terminal, so a teardown failure masks the provider's error

2 participants