fix(voice): flush final agent speech in RecorderIO on session teardown - #2037
Merged
toubatbrian merged 1 commit intoJul 16, 2026
Merged
Conversation
Agent audio only reaches the recorder's encoder via onPlaybackFinished.
On a force-interrupted shutdown, interrupt({ force: true }) marks the
current speech done before playout settles, so RecorderIO.close() raised
its shutdown fence before the in-flight playbackFinished flush landed,
silently dropping the last agent turn and trailing mic audio from the
recording.
RecorderIO.close() now waits (bounded, 2s) for the pending playback
event — which carries the authoritative playback position — before
fencing writers out, warns if unflushed agent audio had to be dropped,
and flushes input captured since the last forward tick so the recording
tail isn't lost.
Fixes AGT-3135
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
toubatbrian
approved these changes
Jul 16, 2026
Contributor
|
@claude add a patch changeset |
toubatbrian
deleted the
chenghao/fix/AGT-3135-recorder-final-speech-flush
branch
July 16, 2026 23:17
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes AGT-3135
Bug: session recordings silently lose the final agent turn when teardown interrupts mid-speech: force-interrupt (#1100) marks speech done instantly, so
RecorderIO.close()fences writers before the in-flightplaybackFinishedflush lands (a production session lost its final 9.6s turn this way).Fix:
close()now waits (2s cap) for the real playback event, whose position is authoritative, instead of estimating one from wall clock; warns if audio is still dropped; and flushes mic input captured since the last forward tick. Python already waits for real speech completion, so it is unaffected.Tests reproduce the close race against real ffmpeg; all three fail without the fix.
🤖 Generated with Claude Code