Realtime Session Update Configuration
I maintainer di solito rispondono entro 1 giorno
@LuminaX-alt ci sta già lavorando.
Dal 2/8/2025.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Inizia da openai.resources.beta.realtime.AsyncRealtimeConnection.send e verifica come viene serializzato SessionUpdateEvent con exclude_defaults=True. Confronta il valore predefinito di turn_detection nel modello Session con i valori VAD lato server mostrati negli esempi di SessionCreatedEvent e SessionUpdatedEvent. Il lavoro è completato quando un SessionUpdateEvent con turn_detection=None può modificare la configurazione della sessione realtime come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 31.8k
- Fork
- 7.3k
- Merge medio
- 1g 4h
- PR unite (30g)
- 126
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openai/openai-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-python#4022 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providersForse già presa @mohmedmm l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
openai/openai-python#4017 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Querystring drops explicit empty-string scalar valuesForse già presa @sylvesterkaczmarek l’ha presa 27 giorni fa. Apertasdk-breaking-change v4
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
openai/openai-python#3837 ·
I maintainer di solito rispondono entro 1 giorno
-
Define + export `ServiceTiers` string literalForse già presa @SparshGarg999 l’ha presa 53 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openai/openai-python#3556 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Empty OPENAI_BASE_URL prevents fallback to default API endpointForse già presa @Sehastrajit-S l’ha presa 19 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openai/openai-python#2927 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openai/openai-python
Issue simili
-
defect from-review v0.9.2
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
khuisman/mcp-gee-sweet#926 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 84/100
EtanHey/brainlayer#1164 ·
I maintainer di solito rispondono entro 1 giorno
-
bug security
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
yunaremaia/vibeguard#141 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PrismorSec/prismor#599 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
iii-hq/iii#2278 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno