Skip to content

fix(voice): don't raise when interrupting a cancelled or finished speech - #6767

Merged
longcw merged 1 commit into
mainfrom
longc/interrupt-done-speech-noop
Aug 10, 2026
Merged

longcw merged 1 commit into
mainfrom
longc/interrupt-done-speech-noop

Conversation

@longcw

@longcw longcw commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Problem

SpeechHandle.interrupt() tested allow_interruptions before it tested the state of the handle, so a handle with allow_interruptions=False raised RuntimeError even after it was interrupted or done.

The allow_interruptions setter already refuses to set protection on a handle that is interrupted, because protection has no meaning in that state. interrupt() did not agree with it.

Callers that walk a group of handles then need a special case for handles that can never play. In AgentActivity.interrupt() (added in #6644), a queued protected handle that the caller already cancelled stopped the queue walk. The interruptible speeches behind it kept playing, and the warning named a handle that never plays.

Reachable today: session.say("hold please", allow_interruptions=False) queues behind another speech, and the caller cancels the returned handle with handle.interrupt(force=True). The handle stays in _speech_q until the scheduling task drops it. A session.interrupt() in that window stops at the dead handle.

Change

interrupt() returns the handle unchanged when it is interrupted or done, before the allow_interruptions test. Task.cancel() and Future.cancel() do the same on work that is finished.

AgentActivity.interrupt() needs no change. The walk stops seeing a RuntimeError that it must not see.

One behavior change: session.interrupt(force=True) followed by session.interrupt() no longer raises on a protected current speech.

SpeechHandle.interrupt() tested allow_interruptions before the state of
the handle, so a protected handle raised RuntimeError even after it was
interrupted or done. The allow_interruptions setter already refuses to
set protection on an interrupted handle, because protection has no
meaning in that state.

Callers that walk a group of handles then need a special case for handles
that can never play. In AgentActivity.interrupt(), a queued protected
handle that the caller already cancelled stopped the queue walk, and the
interruptible speeches behind it kept playing.

session.interrupt(force=True) followed by session.interrupt() no longer
raises on a protected current speech.
@longcw
longcw requested a review from a team as a code owner August 10, 2026 11:51

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

Copy link
Copy Markdown
Contributor

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 1 additional finding.

Open in Devin Review

@longcw
longcw merged commit 060f107 into main Aug 10, 2026
26 checks passed
@longcw
longcw deleted the longc/interrupt-done-speech-noop branch August 10, 2026 12:01
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.

2 participants