fix: reject premature Chat Completions stream EOF - #5211
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93233dac21
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
markstuart-oai
left a comment
There was a problem hiding this comment.
Reviewed af0ea10395d6961656ea4b796c20e22f5a5121e9. No actionable findings. Official OpenAI streams now need a real terminal choice before final completion; buffering preserves that evidence instead of fabricating it. The EOF path retains request usage for tracing and closes the stream, while third-party EOF behavior and valid length/tool completions remain supported. The real-parser Runner regressions cover failure before tool execution and successful terminal paths.
All 22 hosted checks passed on this commit. Validation here was source inspection plus hosted CI; I did not run repository tests.
Summary
This pull request fixes premature Chat Completions stream termination being reported as a successful, truncated response. For the official OpenAI endpoint, streams now require a provider finish reason for choice zero before completing; otherwise they raise
ModelBehaviorErrorbefore tool execution. Interrupted requests remain counted in generation spans even when no usage trailer arrives.Tool-call buffering preserves real terminal choices instead of synthesizing completion at EOF. Third-party adapter behavior, nonempty
lengthcompletions, content filtering, and usage trailers remain supported.Test plan
AsyncOpenAIparser andRunner.run_streamed, covering premature text/tool/empty EOF, normal text and tool completion, buffering, usage, and third-party compatibility.Issue number
No linked issue.
Checks
.agents/skills/code-change-verification/scripts/run.sh