Skip to content

fix: clear stale paused speech state across generation steps#5594

Merged
longcw merged 1 commit intomainfrom
longc/fix-paused-speech-leak
Apr 30, 2026
Merged

fix: clear stale paused speech state across generation steps#5594
longcw merged 1 commit intomainfrom
longc/fix-paused-speech-leak

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented Apr 29, 2026

Summary

Alternative fix for the bug described in #5533.

When a SpeechHandle advances through multiple generation steps within a single turn (e.g. a silent tool-call step followed by a tool-reply step), the false-interruption _paused_speech state captured during an earlier step could leak into the next step.

This fix resets _paused_speech — together with the matching false-interruption timer and the paused audio output — at the scheduling-loop boundary in _scheduling_task, right after each generation step finishes. The next step that runs on the same SpeechHandle then records fresh paused state with the correct agent_state.

When a SpeechHandle advances through multiple generation steps (e.g.
silent tool call followed by a tool reply), false-interruption pause
state captured during an earlier step could leak into the next step,
causing the agent to restore to a stale agent_state on resume.

Reset _paused_speech (and the matching false-interruption timer +
audio output) at the scheduling-loop boundary between generation
steps for the same SpeechHandle, so the next step records fresh state.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@longcw longcw merged commit f8efe43 into main Apr 30, 2026
27 checks passed
@longcw longcw deleted the longc/fix-paused-speech-leak branch April 30, 2026 05:33
Copy link
Copy Markdown
Contributor

This is an automated Claude Code Routine created by @toubatbrian. Right now it is in experimentation stage. The automation will start porting this PR into agents-js automatically.

This PR (fix: clear stale paused speech state across generation steps) was identified as a core runtime fix to _scheduling_task in agent_activity.py. The base resume_false_interruption feature has already been ported to agents-js (see livekit/agents-js#1320), so the leak fix can be applied there too. A follow-up PR against livekit/agents-js will be opened shortly.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants