Skip to content

Fix Realtime example keepalive while awaiting input - #4207

Merged
markstuart-oai merged 2 commits into
mainfrom
codex/fix-realtime-input-ping
Oct 29, 2026
Merged

markstuart-oai merged 2 commits into
mainfrom
codex/fix-realtime-input-ping

Conversation

@markstuart-oai

@markstuart-oai markstuart-oai commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The interactive Realtime example previously blocked WebSocket processing while input() waited for a message, so it could miss server pings. Use the SDK's synchronous Realtime connection, which handles socket reads while the main thread waits for console input. This also preserves prompt Ctrl+C exit without a blocked input worker.

The subprocess regression tests run the actual example against a local WebSocket peer. They check idle pongs, a streamed response followed by another prompt, normal quit, EOF, and SIGINT without another input line. The test reads the server socket through its iterable interface.

Validation: the exact sample passed on OpenAI SDKs 3.40.0 and 3.41.0 with websockets 13.0 and 15.0.1. Additional Linux terminal checks covered Ctrl+C sent through a controlling PTY. The three committed regression cases and focused Ruff formatting, Ruff lint, and ty checks pass. Windows console-signal behavior was not exercised locally.

@markstuart-oai
markstuart-oai requested a review from a team as a code owner October 28, 2026 22:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-10-28T23:18:44.328746Z 1a05a26 Manual request
🔒 Security Review ✅ Completed 2026-10-28T23:19:06.567386Z 1a05a26 Manual request
ℹ️ 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.

Comment thread examples/realtime/realtime.py Outdated

@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: ead03d3104

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread examples/realtime/realtime.py Outdated

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes: confirmed the existing Ctrl-C shutdown regression in #4207 (comment). Moving input() to the default executor lets pings run, but cancelling the await does not interrupt the blocked input worker; asyncio.run waits for executor shutdown. Preserve timely SIGINT exit without another input line and add that subprocess regression. Referencing the existing finding rather than duplicating its inline comment.

Hosted lint also fails at tests/lib/test_realtime_example_keepalive.py:21 because server.sockets is typed Iterable[socket], which cannot be indexed. Use iterator access or materialize the iterable. Other hosted checks are still running. Static review with an independent reviewer; no candidate code or tests executed.

@markstuart-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 1a05a26209

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1a05a26209

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-reviewed the complete updated diff and author replies, with an independent static pass. The synchronous Realtime client keeps input() on the main thread while the WebSocket reader handles pings, addressing the Ctrl-C shutdown finding. Context-manager cleanup remains in place for quit, EOF and interruption. The regression covers conversation output, pongs at both prompts, and prompt exit without another input line; iterator access also fixes the server.sockets typing error. No remaining actionable findings.

Hosted checks pass or skip, including lint and Python 3.10/3.14 tests. No candidate code or local tests executed during review.

@markstuart-oai
markstuart-oai added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit ca1217c Oct 29, 2026
26 checks passed
@markstuart-oai
markstuart-oai deleted the codex/fix-realtime-input-ping branch October 29, 2026 05:20
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.

3 participants