Realtime Session Update Configuration
メンテナーはふだん 1 日以内に返信
@LuminaX-alt がすでに取り組んでいます。
2025年8月2日 から。
評価
調査の方向性
openai.resources.beta.realtime.AsyncRealtimeConnection.send から開始し、SessionUpdateEvent が exclude_defaults=True でどのようにシリアライズされるかを確認します。Session モデルの turn_detection のデフォルト値と、SessionCreatedEvent および SessionUpdatedEvent の例に示されているサーバー側の VAD 値を比較します。turn_detection=None を指定した SessionUpdateEvent によって、意図したとおりに realtime セッションの設定を変更できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
The intended behavior is to disable server-side VAD for the OpenAI Realtime model. We are using LiveKit to facilitate the websocket connection, but the bug is in the OpenAI library.
In particular, the openai.resources.beta.realtime.AsyncRealtimeConnection.send method uses event.to_json(use_api_names=True, exclude_defaults=True, exclude_unset=True) to serialize the SessionUpdateEvent. The issue is with the exclude_defaults=True parameter which doesn't include any values that are equal to their default values.
We have confirmed the two serial SessionUpdateEvents get composed, so a change from the first event is reflected in the resulting configuration of the second event. This makes the exclude_defaults=True argument particularly problematic because there is now no way to ever change a default and then change it back.
There are a couple of problems here. For VAD in particular, despite the default value of turn_detection=None in Session(BaseModel), it is in fact not None and instead some default server-side VAD values. When you try to pass None in the SessionUpdateEvent you can't change the turn_detection value because (1) exclude_defaults=True prevents you and (2) the default value is inconsistent with what actually exists by default.
There are two solutions:
- Remove
exclude_defaults=True - Update the default
turn_detectioninSession
To Reproduce
Please follow the steps below.
Code snippets
When running python minimal_worker.py console using LiveKit agents on branch dev-1.0 with the following model configuration:
agent = VoiceAgent(
instructions="You are a helpful assistant that can answer questions and help with tasks.",
llm=openai.realtime.RealtimeModel(
model="gpt-4o-realtime-preview-2024-12-17",
voice="alloy"
)
)
Then, within the _main_task of RealtimeSession, we hardcode the turn_detection=None parameter as follows:
self._msg_ch.send_nowait(
SessionUpdateEvent(
type="session.update",
session=session_update_event.Session(
model=self._realtime_model._opts.model, # type: ignore
voice=self._realtime_model._opts.voice, # type: ignore
input_audio_transcription=input_audio_transcription,
turn_detection=None
),
event_id=utils.shortuuid("session_update_"),
)
)
The issue here is that turn_detection never gets updated properly according to the SessionUpdatedEvent. This is related to the problem that this PR was attempting to solve.
For example, we get:
- The
SessionCreatedEventwith the defaultturn_detector. By the way, even after passing the query param to the websocket uriturn_detector=for a null value, it still returns with server-side VAD.
SessionCreatedEvent(..., turn_detection=TurnDetection(create_response=True, interrupt_response=True, prefix_padding_ms=300, silence_duration_ms=200, threshold=0.5, type='server_vad'), ...) type='session.created')
- After passing the
turn_detector=Noneargument to theSessionUpdateEventas mentioned above, we still eventually observe theSessionUpdatedEvent.
SessionUpdatedEvent(..., turn_detection=TurnDetection(create_response=True, interrupt_response=True, prefix_padding_ms=300, silence_duration_ms=200, threshold=0.5, type='server_vad'), ...), type='session.updated')
OS
macOS
Python version
Python v3.13
Library version
openai v1.66.3
- 主要言語
- Python
- スター
- 31.8k
- フォーク
- 7.3k
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 126
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openai/openai-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
openai/openai-python#4022 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providers対応中かも @mohmedmm が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
openai/openai-python#4017 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Querystring drops explicit empty-string scalar values対応中かも @sylvesterkaczmarek が 27 日前に担当しました。 オープンsdk-breaking-change v4
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
openai/openai-python#3837 ·
メンテナーはふだん 1 日以内に返信
-
Define + export `ServiceTiers` string literal対応中かも @SparshGarg999 が 53 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
openai/openai-python#3556 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Empty OPENAI_BASE_URL prevents fallback to default API endpoint対応中かも @Sehastrajit-S が 20 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
openai/openai-python#2927 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
openai/openai-python の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
Harmony OPeNDAP SubSetter (HOSS) Geographic LARC_CLOUD PREFIRE_SAT2_AUX-SAT R01 production
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nasa/harmony-autotester#245 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Deltares/imod-python#1928 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
feature
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100