Skip to content

fix(proxy): finalize unterminated response streams - #894

Closed
Komzpa wants to merge 4 commits into
Soju06:mainfrom
Komzpa:fix/stream-terminal-finalization
Closed

Komzpa wants to merge 4 commits into
Soju06:mainfrom
Komzpa:fix/stream-terminal-finalization

Conversation

@Komzpa

@Komzpa Komzpa commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Superseded

This PR has been absorbed into #892 so Responses HTTP bridge and stream-correctness fixes land in one reviewable branch.

#892 now carries this PR's terminal-event requirement and stream_incomplete handling for unterminated raw HTTP Responses streams.

Relationship:

@Komzpa
Komzpa force-pushed the fix/stream-terminal-finalization branch 2 times, most recently from ab6d52c to f1513d3 Compare June 3, 2026 09:22
@Komzpa

Komzpa commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1513d3d75

ℹ️ 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".

Comment thread app/modules/proxy/service.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@Komzpa
Komzpa force-pushed the fix/stream-terminal-finalization branch from f1513d3 to 8bf0f0d Compare June 3, 2026 09:45
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bf0f0dad7

ℹ️ 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".

Comment thread app/modules/proxy/service.py Resolved
@Komzpa
Komzpa force-pushed the fix/stream-terminal-finalization branch from 8bf0f0d to 03fce2c Compare June 3, 2026 10:10
@Komzpa
Komzpa force-pushed the fix/stream-terminal-finalization branch from 03fce2c to 033d737 Compare June 3, 2026 10:12
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

@Komzpa Komzpa added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 3, 2026
@Soju06 Soju06 removed the 🤖 codex: ok [@codex review] says no issues found. label Jun 3, 2026
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b356efb8f

ℹ️ 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".

Comment thread app/modules/proxy/service.py Outdated
Comment on lines +12581 to +12585
else:
classify_unterminated_stream(
error_status="error",
error_code_value="client_disconnected",
error_message_value="Downstream client disconnected before response.completed",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid classifying uncaught stream errors as client disconnects

This else branch runs in finally for any non-exhausted exit while the status is still success, not only for downstream cancellation. If an upstream iterator or post-event processing step raises an ordinary exception after a non-terminal event, _stream_once reaches this branch, logs client_disconnected, and suppresses account health handling before the outer stream wrapper emits upstream_error; the explicit CancelledError/GeneratorExit handler above already covers real disconnects, so this fallback should not relabel unrelated exceptions as downstream closes.

Useful? React with 👍 / 👎.

@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

if not seen_terminal:
error_code = "stream_incomplete"
error_message = "Upstream closed stream without completion"

P1 Badge Treat terminal error events as completed streams

When the upstream stream legitimately ends with an SSE error event, this new EOF check still appends a synthetic response.failed/stream_incomplete because the core terminal set only includes response.completed, response.failed, and response.incomplete (app/core/clients/proxy.py:99-105), while the service/spec explicitly treat error as terminal. In that scenario downstream clients receive an extra terminal failure and the later stream_incomplete can overwrite the real upstream error in settlement/logging, so this EOF path should not run after an observed error event.

ℹ️ 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".

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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".

@Soju06 Soju06 added the 🤖 codex: ok [@codex review] says no issues found. label Jun 3, 2026
@Komzpa

Komzpa commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as absorbed by #892.

#892 now carries this PR's terminal-event and stream_incomplete behavior for unterminated raw HTTP Responses streams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 codex: ok [@codex review] says no issues found.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants