Repository navigation
fix(speech): replay and STT update work after agent playback ends - #306
Merged
Merged
Conversation
arm_stt_hold_if_idle set stt_finalize_pending after agent TTS playback even when the previous utterance was already finalized. should_finalize_utterance needs !stt_final_emitted_this_utterance, so the flag stayed set until the next SpeechStart and utterance_in_progress() kept deferring update_stt_config and rejecting replay_last_utterance. Skip arming the hold when no caller utterance is open, and ignore a pending finalize in utterance_in_progress when the final was already emitted. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Problem
After agent TTS playback ended,
updateSttwas deferred andreplayLastUtterancefailed with "cannot replay while an utterance is in progress", even though the caller's final had landed long before and the caller was silent. This lasted until the caller spoke again.Cause:
end_agent_speaking_innercallsarm_stt_hold_if_idle, which setstt_gate_hold_msandstt_finalize_pendingwhenever VAD was not speaking, including when no caller utterance was open. The previous utterance already hasstt_final_emitted_this_utterance = true, soshould_finalize_utterancenever fires andstt_finalize_pendingstays set until the nextSpeechStart.utterance_in_progress()then reports true.This breaks the pattern "final → agent says 'one moment' →
updateStt→replayLastUtterance".Fix
arm_stt_hold_if_idleno longer arms when the previous utterance is complete and nothing new started.utterance_in_progressignores a pending finalize for an utterance whose final was already emitted, because it can never complete. This also covers a vendor final that arrives before VADSpeechEnd.Tests
New
crates/speech/tests/replay_after_agent_playback_test.rs:updateSttapplies at once and the firstreplayLastUtterancecall succeeds after agent playback, after non-interruptible playback, and immediately atagent_speaking_end. All three failed before the fix.Verified locally and in CI; no extra manual steps.
🤖 Generated with Claude Code