fix(voice): export uncommitted user_turn spans on close - #6592
Open
chenghao-mou wants to merge 2 commits into
Open
fix(voice): export uncommitted user_turn spans on close#6592chenghao-mou wants to merge 2 commits into
chenghao-mou wants to merge 2 commits into
Conversation
VAD opens the user_turn span before a transcript exists. The eou detection is the only path that ends it, and _aclose cancels that task, so a turn that never committed left the span recording and OpenTelemetry never exported it: user_speaking children shipped without their parent. End the span in a finally block once recognition stopped. Ports livekit/agents-js#2062 to Python. Co-Authored-By: Claude Opus 5 (1M context) <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.
Fixes AGT-3200. Ports livekit/agents-js#2062 (AGT-3154) to Python.
VAD opens the
user_turnspan before a transcript exists. The eou detection is the only path that ends it, and_aclosecancels that task, so a turn that never committed left the span recording and OpenTelemetry never exported it:user_speakingchildren shipped without their parent, and the transcript attributes set at span end never left the process. Closing withCloseReason.ERRORskips the closingcommit_user_turnentirely, so it always lost the span.Span teardown moves into
_end_user_turn_span(), reused byclear_user_turnand called from afinallyin_aclose(the JS fix ends it on the happy path only; teardown raising is exactly the error close that leaks).Noticed, not fixed: the JS helper also clears
userTurnStart; Python clears_user_turn_starton the eou path but not inclear_user_turn, so a stale start time back-dates the next turn's span. Worth a separate look.