Repository navigation
fix(desktop): rotate expired OpenAI realtime sessions - #9672
Merged
Merged
Conversation
kodjima33
added a commit
that referenced
this pull request
Jul 15, 2026
…9666) (#9789) macOS RealtimeHub rotates OpenAI sessions at the 60-minute limit, but a write that races the provider close surfaces the retired socket as `Socket is not connected` (ENOTCONN). That message matched no lifecycle category, so it was logged error-level to Sentry — the residual `Socket is not connected` cluster still firing on stable/beta cohorts after the rotation fix (#9672) landed. Root cause: the ENOTCONN close on an already-aged, idle socket is an expected transport teardown, not a provider error. The re-warm already happens; only the classification (and thus the error-level Sentry event) was wrong. Fix: recognize ENOTCONN on an aged idle socket (aliveFor >= idle threshold, no active turn) as `.expectedIdleTeardown`, mirroring the existing 1008 idle-close gate — quiet re-warm, no Sentry error. A fast ENOTCONN or one during an active turn still falls through and remains a reportable error, so genuine transport failures stay observable. Tests: 3 new classifier cases (aged-idle → expected/no-report, active-turn → reportable, fast → reportable). Full package builds; all 13 RealtimeHubCloseClassifierTests pass. 🤖 automated by hourly watchdog; opened for review, not merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VoiceTurnCoordinatorterminal lifecycle; the next PTT uses the fresh, healthy session.Root cause
RealtimeHubCloseClassifierrecognized only WebSocket 1008 lifecycle closes. OpenAI reports its maximum-duration expiry with a distinct message, so it bypassed expected-close handling and could surface as an error instead of a routine transport rotation.Durable guard
The typed session-rotation plan distinguishes idle re-warm from active-turn terminalization. Focused tests cover OpenAI-only classification, Sentry suppression, reducer exactly-once terminal behavior, and bounded diagnostic recovery metadata.
Verification
cd desktop/macos && xcrun swift test --package-path Desktop --filter 'RealtimeHubCloseClassifierTests|VoiceTurnReducerTests|DesktopDiagnosticsManagerTests'— 68 passed.cd desktop/macos && ./scripts/agent-logic-harness.sh— passed (502 agent-runtime tests and 104 pi-mono package tests).omi-realtime-rotation:omi-ctl action ptt_test_turn ...completed a real controller PTT turn using the fresh OpenAI transport and persisted the forced transcript.OMI_PR_BODY_FILE=/tmp/omi-pr-body.md make preflight— passed (14 checks).Product invariants affected
INV-CHAT-1INV-VOICE-1Closes #9666
Closes #9667