fix(responses): preserve terminal errors through stream cleanup - #5187
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
left a comment
There was a problem hiding this comment.
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.
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 recognizeserroras terminal in the request-ID stream wrapper.Adding
errorto 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
error/response.failed/response.incompletecases fail before the fix.Issue number
Fixes #5181
Checks
.agents/skills/code-change-verification/scripts/run.sh