Skip to content

fix(desktop): rotate expired OpenAI realtime sessions - #9672

Merged
Git-on-my-level merged 1 commit into
mainfrom
codex/realtime-session-rotation
Jul 14, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
codex/realtime-session-rotation

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Classify OpenAI's 60-minute Realtime expiry as an expected session-rotation condition and immediately create a replacement transport.
  • Route an interrupted active PTT turn through the existing VoiceTurnCoordinator terminal lifecycle; the next PTT uses the fresh, healthy session.
  • Emit a safe, non-error desktop health event and add classifier, reducer, and diagnostics regression coverage.

Root cause

RealtimeHubCloseClassifier recognized 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).
  • Named local bundle 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).
  • Pre-push hook — passed, including full desktop Swift build.

Product invariants affected

  • INV-CHAT-1
  • INV-VOICE-1

Closes #9666
Closes #9667

Review in cubic

@Git-on-my-level
Git-on-my-level merged commit c66dcc2 into main Jul 14, 2026
22 of 25 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/realtime-session-rotation branch July 14, 2026 02:03
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant