Skip to content

fix(voice): race between flush and clear_buffer on interrupt leaks unplayed transcript#5798

Merged
longcw merged 1 commit into
mainfrom
longc/fix-interrupt-leak-full-transcript
May 21, 2026
Merged

fix(voice): race between flush and clear_buffer on interrupt leaks unplayed transcript#5798
longcw merged 1 commit into
mainfrom
longc/fix-interrupt-leak-full-transcript

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented May 21, 2026

Summary

  • When a speech was interrupted right around playout, the full reply text could leak into the chat context. The cancelled _audio_forwarding_task called flush() in its finally block, which let the tiny in-flight audio drain naturally and report interrupted=False before agent_activity's clear_buffer() could mark it interrupted. The synchronizer then treated playback as completed and returned the full pushed text as the synchronized transcript.
  • Call clear_buffer() from the cancelled task's finally so the interrupt signal lands before any natural completion event fires.

When a speech was interrupted right around playout, the entire reply text
could leak into the chat context. The cancelled `_audio_forwarding_task`
called `flush()` in its finally block, which let the tiny in-flight audio
drain naturally and report `interrupted=False` before agent_activity's
`clear_buffer()` could mark it interrupted. The synchronizer then treated
playback as completed and returned the full pushed text as the
synchronized transcript.

Call `clear_buffer()` from the cancelled task's finally so the
interruption signal lands before any natural completion event fires. Also
read `_interrupted_event` directly in `_ParticipantAudioOutput` so the
interrupted flag isn't lost when both wait futures complete in the same
loop tick.
@chenghao-mou chenghao-mou requested a review from a team May 21, 2026 09:48
@longcw longcw changed the title fix(voice): drop unplayed transcript on interruption fix(voice): race between flush and clear_buffer on interrupt leaks unplayed transcript May 21, 2026
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 3 additional findings.

Open in Devin Review

@longcw longcw merged commit 350e516 into main May 21, 2026
26 checks passed
@longcw longcw deleted the longc/fix-interrupt-leak-full-transcript branch May 21, 2026 14:16
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