Skip to content

fix(voice): flush final agent speech in RecorderIO on session teardown - #2037

Merged
toubatbrian merged 1 commit into
mainfrom
chenghao/fix/AGT-3135-recorder-final-speech-flush
Jul 16, 2026
Merged

fix(voice): flush final agent speech in RecorderIO on session teardown#2037
toubatbrian merged 1 commit into
mainfrom
chenghao/fix/AGT-3135-recorder-final-speech-flush

Conversation

@chenghao-mou

@chenghao-mou chenghao-mou commented Jul 15, 2026

Copy link
Copy Markdown
Member

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-flight playbackFinished flush 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

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>
@chenghao-mou
chenghao-mou requested a review from a team as a code owner July 15, 2026 09:40

@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 bugs or issues to report.

Open in Devin Review

@toubatbrian

Copy link
Copy Markdown
Contributor

@claude add a patch changeset

@toubatbrian
toubatbrian merged commit dfd6654 into main Jul 16, 2026
9 checks passed
@toubatbrian
toubatbrian deleted the chenghao/fix/AGT-3135-recorder-final-speech-flush branch July 16, 2026 23:17
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants