Realtime Session Update Configuration
Les mainteneurs répondent en général sous 1 jour
@LuminaX-alt y travaille déjà.
Depuis le 2/8/2025.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 42/100
Piste de recherche
Commencez dans openai.resources.beta.realtime.AsyncRealtimeConnection.send et examinez comment SessionUpdateEvent est sérialisé avec exclude_defaults=True. Comparez la valeur par défaut de turn_detection dans le modèle Session avec les valeurs VAD côté serveur affichées dans les exemples de SessionCreatedEvent et SessionUpdatedEvent. Le travail est terminé lorsqu’un SessionUpdateEvent avec turn_detection=None peut modifier la configuration de la session realtime comme prévu.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Python
- Étoiles
- 31.8k
- Forks
- 7.3k
- Merge moyen
- 1 j 3 h
- PR mergées (30 j)
- 128
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de openai/openai-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
openai/openai-python#4022 · 6 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providersPeut-être pris @mohmedmm l’a pris il y a 5 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
openai/openai-python#4017 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Querystring drops explicit empty-string scalar valuesPeut-être pris @sylvesterkaczmarek l’a pris il y a 27 jours. Ouvertesdk-breaking-change v4
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
openai/openai-python#3837 ·
Les mainteneurs répondent en général sous 1 jour
-
Define + export `ServiceTiers` string literalPeut-être pris @SparshGarg999 l’a pris il y a 54 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
openai/openai-python#3556 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Empty OPENAI_BASE_URL prevents fallback to default API endpointPeut-être pris @Sehastrajit-S l’a pris il y a 20 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
openai/openai-python#2927 · 7 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de openai/openai-python
Issues similaires
-
area/install reliability
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
FluidNumerics/fluid-walk-blocker#191 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
TransformerLensOrg/TransformerLens#1868 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
climate-analytics-lab/jax-gcm#1057 ·
Les mainteneurs répondent en général sous 1 jour