Skip to content

: Regression in 1.3.2: race in AgentActivity.userTurnCompleted swallows the user's next turn when resumeFalseInterruption is enabled #1430

@eduhermidafonetic

Description

@eduhermidafonetic

Describe the bug

Symptoms

User barges in early when agent starts speaking, maybe 1-2 seconds after the agent starts speaking
STT transcribes the new user utterance correctly (we see final transcript and userTurnCompleted started).
Aborting all pipeline reply tasks due to interruption fires, then userTurnCompleted done.
No Creating speech handle / generateReply is ever emitted for the new turn. The agent goes silent.
~10s later: User away timeout triggered.

Disabling resumeFalseInterruption (or downgrading to 1.2.8) avoids it.

Root cause

In dist/voice/agent_activity.js [AgentActivity.userTurnCompleted]~lines 1212–1240):

if (this._currentSpeech) {
if (!this._currentSpeech.allowInterruptions) { /* ... / return; }
await this.cancelSpeechPause();
this.logger.info({ "speech id": this._currentSpeech.id }, /
... */); // TypeError
this._currentSpeech.interrupt();
}

[cancelSpeechPause()] awaits [pausedSpeech.handle._waitForGeneration()] While that promise is pending, the speech's mainTask runs to completion and resets this._currentSpeech = undefined. When the await resolves, accessing this._currentSpeech.id throws TypeError: Cannot read properties of undefined (reading 'id').

The exception escapes inside the EOU handler task and is silently swallowed by an outer .catch, so the pipeline never proceeds to scheduling a reply for the new user turn. The session stays "thinking" until userAwayTimeout.

Proposed fix

Capture the speech handle into a local before awaiting:

if (this._currentSpeech) {
const speech = this._currentSpeech;
if (!speech.allowInterruptions) { /* ... */ return; }
await this.cancelSpeechPause();
this.logger.info({ "speech id": speech.id }, "interrupting current speech ...");
speech.interrupt();
}

Relevant log output

09:05:52.880 final transcript: "..."
09:05:52.881 userTurnCompleted started
09:05:52.882 Aborting all pipeline reply tasks due to interruption
09:05:52.934 userTurnCompleted done
<-- expected: "Creating speech handle" — never fires
09:06:02.692 User away timeout triggered

Describe your environment

Node 20,
Pipeline Deepgram STT (en-GB) → OpenAI gpt-5.1 → ElevenLabs TTS (eleven_turbo_v2_5)
Silero VAD with VAD-based turn detection

Minimal reproducible example

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions