fix(google): omit session_resumption when handle is None - #7254
Conversation
Passing SessionResumptionConfig(handle=None) on initial connection causes Gemini Realtime API to reject the connection with 1008 policy violation. Only include SessionResumptionConfig in LiveConnectConfig when a handle is present. Fixes livekit#5102
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46535fa255
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if self._session_resumption_handle is not None | ||
| else None |
There was a problem hiding this comment.
Preserve explicit resumption config before a handle exists
When a caller explicitly enables session resumption for a fresh supported Live session, for example with SessionResumptionConfig(transparent=True), the handle is necessarily None until the server issues the first one. This condition silently drops the caller's entire configuration, so the server is not asked to provide resumption updates and a later reconnect cannot resume the session. Omit the field only when no configuration was supplied and no handle exists; an explicitly supplied handle-less configuration still needs to be sent.
Useful? React with 👍 / 👎.
|
Addressed the review feedback:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 807eccfddc
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| is_given(self._opts.session_resumption) | ||
| and self._opts.session_resumption.transparent is not None |
There was a problem hiding this comment.
Preserve explicit empty resumption requests
On a supported Live model, SessionResumptionConfig() is the normal initial opt-in for nontransparent session resumption: it has neither a prior handle nor a transparent value, but its presence requests the updates that will supply the first handle. This condition treats that explicit request exactly like NOT_GIVEN, so the server is never asked for updates and the session can never acquire a handle to resume with. The newly added test_empty_session_resumption_config_is_omitted is fresh evidence for this remaining case after the earlier comment's transparent=True example was fixed; distinguish an explicitly supplied empty config from an omitted option.
Useful? React with 👍 / 👎.
|
Fixed: Guarded against empty |
|
Addressed review feedback: preserved explicitly provided |
Summary
When connecting to the Gemini Realtime API,
_build_connect_configunconditionally set:On initial connect,
self._session_resumption_handleisNone. PassingSessionResumptionConfig(handle=None)causes Gemini Realtime (e.g.gemini-2.5-flash-native-audio-latest) to reject the WebSocket connection with error 1008 (policy violation).This change only includes
session_resumptioninLiveConnectConfigwhen_session_resumption_handleis notNone, preservingtransparentif configured.Fixes #5102
Testing
tests/test_plugin_google_realtime.pyverifying that:session_resumptionisNonewhen connecting without a prior handle.session_resumptionis populated when a handle is configured.uv run pytest tests/test_plugin_google_realtime.pypassed (28 tests).uv run ruff checkpassed.