Skip to content

macOS RealtimeHub: rotate/reconnect OpenAI sessions at the 60-minute limit without surfacing an error #9666

Description

@Git-on-my-level

Summary

macOS Desktop should treat OpenAI Realtime’s 60-minute session limit as a normal session-rotation condition, not an unclassified error. Today an expired warm socket can be reported as an error and later writes can hit a disconnected socket.

This is a focused provider-lifecycle/recovery bug, not a backend token-mint issue and not a reason to reopen the completed voice ownership convergence work.

User impact

A long-running Desktop session can hit the OpenAI provider’s maximum duration. The next voice interaction may be interrupted or delayed while the client attempts to use the expired socket. The UI must always return to an actionable state and a subsequent PTT interaction must be able to establish a healthy session.

Observed failure sequence

Production Desktop has reported the following pair from the same stable release cohort:

  1. RealtimeHub: session error — provider=openai Your session hit the maximum duration of 60 minutes.
  2. RealtimeHub: session error — provider=openai The operation couldn’t be completed. Socket is not connected

The important behavioral fact is the provider-enforced session expiry followed by a client attempt to use the retired socket. Do not require Sentry access to reproduce, implement, or verify this issue.

Root-cause hypothesis

RealtimeHubCloseClassifier currently recognizes an expected idle teardown only for messages containing WebSocket closed (1008). OpenAI’s maximum-duration close has different text, so it bypasses the expected-lifecycle classification and is emitted as an error. The lifecycle must explicitly model provider session expiry and transition the transport to a reusable/reconnectable state.

Relevant code:

  • desktop/macos/Desktop/Sources/FloatingControlBar/RealtimeHubController.swift
  • desktop/macos/Desktop/Tests/RealtimeHubCloseClassifierTests.swift

Required behavior

  • Recognize the known OpenAI maximum-session-duration close as a typed provider lifecycle condition; do not depend on raw provider text outside the classifier boundary.
  • If no logical voice turn is active, retire and re-warm/reconnect the transport quietly. Do not emit an error-level Sentry event for the expected rotation.
  • If an active voice turn is affected, terminate that turn through the canonical voice lifecycle with an actionable recovery path. The floating-bar/UI projection must return to idle or a defined recoverable state.
  • A subsequent PTT interaction must never attempt to send through the retired socket and must be able to obtain a healthy session.
  • Preserve error-level reporting for genuinely unexpected provider failures, auth/quota failures, and reconnect failures.

Acceptance criteria

  • A focused test covers the OpenAI maximum-duration message and classifies it as an expected session-rotation condition.
  • A lifecycle test covers expiry of a warm session followed by another PTT turn; the next turn uses a healthy transport rather than a disconnected socket.
  • A lifecycle test covers expiry during an active turn; it reaches exactly one terminal outcome and leaves the UI actionable.
  • Expected session rotation is observable through a safe structured metric/breadcrumb or non-error diagnostic, without raw provider payloads or user data.
  • The known expiry no longer creates an error-level Sentry event; unexpected close/reconnect failure remains observable.
  • Run the relevant focused Swift tests and the Desktop voice/realtime harness or gauntlet appropriate to the changed path.

Scope boundaries

  • Do not fold this into Gemini realtime token minting; that is a separate backend request-schema issue.
  • Do not add a second voice-turn owner or a compatibility lifecycle. VoiceTurnCoordinator remains the logical turn owner, while RealtimeHubController remains the socket/audio transport driver.
  • Do not change provider selection, authentication policy, or unrelated PTT capture behavior.

Activity

  1. added
    bug
    p2
    on Jul 14, 2026
  2. added a commit that references this issue on Jul 14, 2026
    c66dcc2
  3. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    Fresh production recurrence (2026-07-15 UTC)

    The exact regression described in this issue is still occurring on the stable 0.12.70+12070 cohort:

    • RealtimeHub: ... maximum duration of 60 minutes is escalating.
    • A distinct Socket is not connected group is present and includes both 0.12.70+12070 and the newly promoted 0.12.73+12073 cohorts.

    This matches provider-enforced expiry followed by an attempt to use a retired transport. The original acceptance criteria remain appropriate; re-opening for a focused source/test review. No user identifiers, payloads, or tokens included.

  4. Git-on-my-level commented on Jul 15, 2026

    @Git-on-my-level
    MemberAuthor

    Deployment clarification

    PR #9672 is included in beta 0.12.73+12073 (its merge commit is an ancestor of the candidate). However, after beta promotion, the Socket is not connected group recorded a fresh 0.12.73+12073 event.

    So this issue should remain open: either another retired-transport path bypasses the new rotation logic, or the same lifecycle fix is incomplete. The 60-minute-expiry group remains stable-only in the sampled 12-hour evidence, but the disconnected-socket outcome is not fully eliminated in beta.

    No user identifiers or raw event payloads included.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdesktopmacOSp2reliability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions