Skip to content

Commit a0d7905

Browse files
heavygeeHAPI
andcommitted
fix(voice): guard session.updated re-entry and reset config on session start
session.updated now returns early after the first ack — subsequent session.update calls (instruction appends) also echo session.updated but must not re-trigger audio capture or the greeting path. currentSessionConfig is now reset to null at the top of startSession so a stale config from a failed previous session cannot leak into the new one. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
1 parent 5e08f6c commit a0d7905

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

web/src/realtime/QwenVoiceSession.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class QwenVoiceSessionImpl implements VoiceSession {
112112
}
113113

114114
async startSession(config: VoiceSessionConfig): Promise<void> {
115+
this.currentSessionConfig = null
115116
cleanup()
116117
state.statusCallback?.('connecting')
117118

@@ -214,8 +215,11 @@ class QwenVoiceSessionImpl implements VoiceSession {
214215
return
215216
}
216217

217-
// Session updated - ready to go
218+
// Session updated - only act on the first one (initial config ack).
219+
// Subsequent session.update calls (for instruction appends) also
220+
// echo session.updated — ignore those after setup is complete.
218221
if (eventType === 'session.updated') {
222+
if (sessionReady) return
219223
sessionReady = true
220224
if (DEBUG) console.log('[Qwen] Session configured')
221225
try {
@@ -359,6 +363,8 @@ class QwenVoiceSessionImpl implements VoiceSession {
359363
sendTextMessage(message: string): void {
360364
// Qwen only supports conversation.item.create for function_call_output.
361365
// Inject text as an instruction update then trigger a response.
366+
// response.create without a prior conversation.item.create is valid —
367+
// it generates from the current session context (updated instructions).
362368
this.updateInstructions(message)
363369
sendEvent('response.create')
364370
}

0 commit comments

Comments
 (0)