Skip to content

fix(voice): export uncommitted user_turn spans on close - #6592

Open
chenghao-mou wants to merge 2 commits into
mainfrom
chenghao/fix/AGT-3200-export-uncommitted-user-turn-spans
Open

fix(voice): export uncommitted user_turn spans on close#6592
chenghao-mou wants to merge 2 commits into
mainfrom
chenghao/fix/AGT-3200-export-uncommitted-user-turn-spans

Conversation

@chenghao-mou

Copy link
Copy Markdown
Member

Fixes AGT-3200. Ports livekit/agents-js#2062 (AGT-3154) to Python.

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, and the transcript attributes set at span end never left the process. Closing with CloseReason.ERROR skips the closing commit_user_turn entirely, so it always lost the span.

Span teardown moves into _end_user_turn_span(), reused by clear_user_turn and called from a finally in _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_start on the eou path but not in clear_user_turn, so a stale start time back-dates the next turn's span. Worth a separate look.

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>
@chenghao-mou
chenghao-mou requested a review from a team as a code owner July 28, 2026 21:46
devin-ai-integration[bot]

This comment was marked as resolved.

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.

1 participant