Repository navigation
refactor: share WebSocket connection handling - #4084
Conversation
Castiron-Internal-PR: openai/openai-python-internal#256 Castiron-Source-SHA: 46ea721b3232d5eec49eb7f22ec07a08e1e657b7 Castiron-Public-Base-SHA: 95dbee9
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. |
Castiron custom codeEvaluated main: ✅ No new custom-code files detected. 40 mixed files remain; 6 existing customizations changed. Compared
34 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 38677388174 --repo openai/openai-python \
--name castiron-custom-code-38677388174-1 --dir /tmp/castiron-custom-code-38677388174-1
git apply --stat /tmp/castiron-custom-code-38677388174-1/custom-code.patch
cat /tmp/castiron-custom-code-38677388174-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 95dbee9ee406587053a0a21296eb82418073f2aa 25e5587457406a27e6fb2eb349f64566cc19294d
python3 scripts/castiron/custom_code_report.py report \
--base 95dbee9ee406587053a0a21296eb82418073f2aa \
--head 25e5587457406a27e6fb2eb349f64566cc19294d --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-25e558745740
cat /tmp/castiron-custom-code-25e558745740/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
Why
Responses, Realtime, and Live repeat the same WebSocket connection logic. Sharing that code makes fixes apply consistently while preserving each API's current behavior.
High-level description
Move existing send-queue flushing, reconnect, raw-send, and close logic into shared synchronous and asynchronous base classes. Keep public classes, method signatures, connection setup, event types, and API helpers unchanged. Preserve synchronous Responses' ability to interrupt a reconnect when closing.
Add a regression test for close during reconnect across six connection types. This change adds no automatic replay of commands whose delivery is uncertain.
Validation