Fix LLMFullResponseEndFrame racing ahead of final TTSTextFrame#4127
Merged
markbackman merged 2 commits intomainfrom Mar 24, 2026
Merged
Fix LLMFullResponseEndFrame racing ahead of final TTSTextFrame#4127markbackman merged 2 commits intomainfrom
markbackman merged 2 commits intomainfrom
Conversation
Route LLMFullResponseEndFrame through the serialization queue instead of pushing it directly downstream when push_text_frames is enabled. This ensures the frame is emitted only after the audio context is fully drained, preserving correct ordering relative to TTSTextFrames. Previously, the final sentence TTSTextFrame would arrive at the LLMAssistantAggregator after LLMFullResponseEndFrame, causing it to be dropped from the conversation context (especially with RTVI text input where no subsequent interruption would flush the orphaned text).
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
Context
This PR solves the following issue:
When using a TTSService that relies on the TTSService base class to push text frame (e.g.
push_text_frames=True) then the frames pushed by the TTSService for a given turn will be in this order:LLMFullResponseStartFrameTTSTextFrame(#1through#n-1)LLMFullResponseEndFrame#n)This causes a problem in the LLMAssistantAggregator for text input only. Text is added to the context only when between the LLMFullResponseStart/EndFrames. The dangling message was getting dropped from the context.
The solution is to have the TTSService correctly output frames in order. That's what this PR focuses on by using the
serialization_queue.Summary
LLMFullResponseEndFramethrough the TTS serialization queue (instead of pushing directly downstream) whenpush_text_framesis enabledTTSTextFramesTest plan
test_http_push_text_llm_response_end_after_tts_textthat verifies allTTSTextFrames precedeLLMFullResponseEndFrame🤖 Generated with Claude Code
Fixes #4111