Skip to content

Fix dropped fragments in trailing assistant turn#143

Merged
JosephMarinier merged 8 commits into
mainfrom
joseph/fix-trailing-assistant-turn
Jun 10, 2026
Merged

Fix dropped fragments in trailing assistant turn#143
JosephMarinier merged 8 commits into
mainfrom
joseph/fix-trailing-assistant-turn

Conversation

@JosephMarinier

@JosephMarinier JosephMarinier commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

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.

  • Fix dropped fragments in trailing assistant turn
    • Flip if for readability (refactor, no change)

    • Fix dropped fragments in trailing assistant turn
      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].

    • Clean up (refactor, no change)

  • Analysis app (used to investigate this bug)

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]`.
@JosephMarinier JosephMarinier self-assigned this Jun 9, 2026

@gabegma gabegma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!! Can you bump the generic metric versions, as this could impact a few metrics? No need to bump individual ones IMO.

@JosephMarinier JosephMarinier added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit b9d568d Jun 10, 2026
1 check passed
@JosephMarinier JosephMarinier deleted the joseph/fix-trailing-assistant-turn branch June 10, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants