Fix dropped fragments in trailing assistant turn#143
Merged
Conversation
When `last_entry` had an `assistant` role, the cut-off tag was appended to `last_entry["content"]`. Then, that value was also used to overwrite `intended_assistant_turns[trailing_turn_id]` (as well as `transcribed_assistant_turns[trailing_turn_id]` if it was empty). However, `last_entry["content"]` only contains the very last fragment. If the trailing assistant turn had multiple fragments, the other ones were lost. For example, the spoken "I'll transfer you to a live agent right now who can review your case..." was lost, leaving only the synthetic "Transferring you to a live agent. Please wait." that came right after. Now, the cut-off tag is appended independently to `last_entry["content"]`, `intended_assistant_turns[trailing_turn_id]`, as well as `transcribed_assistant_turns[trailing_turn_id]` if it exists, otherwise it falls back to `intended_assistant_turns[trailing_turn_id]`.
gabegma
approved these changes
Jun 9, 2026
gabegma
left a comment
Collaborator
There was a problem hiding this comment.
Thank you!! Can you bump the generic metric versions, as this could impact a few metrics? No need to bump individual ones IMO.
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.
I let PR #120 bump the AgentSpeechFidelityMetric version to avoid conflicts. Let me know if I should bump here instead.
I recommend reviewing the commits individually. Some are trivial to review and remove noise from the complete diff.
Flip if for readability (refactor, no change)
Fix dropped fragments in trailing assistant turn
When
last_entryhad anassistantrole, the cut-off tag was appended tolast_entry["content"]. Then, that value was also used to overwriteintended_assistant_turns[trailing_turn_id](as well astranscribed_assistant_turns[trailing_turn_id]if it was empty). However,last_entry["content"]only contains the very last fragment. If the trailing assistant turn had multiple fragments, the other ones were lost.For example, the spoken "I'll transfer you to a live agent right now who can review your case..." was lost, leaving only the synthetic "Transferring you to a live agent. Please wait." that came right after.
Now, the cut-off tag is appended independently to
last_entry["content"],intended_assistant_turns[trailing_turn_id], as well astranscribed_assistant_turns[trailing_turn_id]if it exists, otherwise it falls back tointended_assistant_turns[trailing_turn_id].Clean up (refactor, no change)
Before:
After: