Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/clear-paused-speech-leak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@livekit/agents': patch
---

fix(voice): clear stale paused-speech state across generation steps

Ports livekit/agents#5594. Resets `pausedSpeech`, the false-interruption
timer, and the paused audio output at the scheduling-loop boundary in
`AgentActivity` after each generation step finishes, so paused state
captured during an earlier silent step (e.g. a silent tool call) does not
leak into the next step on the same `SpeechHandle` (e.g. the tool reply).
16 changes: 16 additions & 0 deletions agents/src/voice/agent_activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,22 @@ export class AgentActivity implements RecognitionHooks {
this._currentSpeech = speechHandle;
speechHandle._authorizeGeneration();
await speechHandle.waitIfNotInterrupted([speechHandle._waitForGeneration()]);

// Ref: python livekit-agents/livekit/agents/voice/agent_activity.py - 1365-1373 lines
// Clear stale paused-speech state captured by an earlier generation step
// (e.g. a silent tool-call step) so it doesn't leak into the next step
// running on the same SpeechHandle (e.g. the tool reply).
if (this.pausedSpeech && this.pausedSpeech.handle === this._currentSpeech) {
this.pausedSpeech = undefined;
if (this.falseInterruptionTimer) {
clearTimeout(this.falseInterruptionTimer);
this.falseInterruptionTimer = undefined;
}
const audioOutput = this.agentSession.output.audio;
if (audioOutput && audioOutput.canPause) {
audioOutput.resume();
}
}
this._currentSpeech = undefined;
}

Expand Down
Loading