Conversation
🦋 Changeset detectedLatest commit: 4c929a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
davidzhao
added this pull request to stack #2502
September 15, 2026 06:32
davidzhao
force-pushed
the
dz/telemetry-eot-wait
branch
from
September 15, 2026 06:46
1dbaa1a to
e6f3e52
Compare
Port of livekit/agents#7130. - `eou_wait` span, one per user turn under `user_turn`, back-dated to the last speaking time and ended on the turn decision with lk.eou.outcome (committed / user_resumed / dropped), lk.eou.wait_duration, lk.eou.rearm_count, lk.eou.not_committed_count and the final lk.eou.endpointing_delay / source. Later triggers for the same turn re-arm the wait (a `rearmed` event) instead of opening a new span; resumed speech ends it at the VAD/STT speech start; a mode change to or from manual and teardown drop it. `eou_detection` now nests under the wait, which owns its early end (`superseded` event) so the child always stays inside the parent. user_turn carries lk.eou.resume_count. - `on_user_turn_completed` span around the user hook, nested under the user_turn it completes: recognition hands the open span to the activity (EndOfTurnInfo userTurnSpan / userTurnSpanAdopted) which ends it after the hook, so the turn covers the wait for the hook. StopResponse is an event; exceptions are recorded redaction-aware, honouring the session's redaction as well as the job's flag. - lk.speech.queue_wait on agent_turn (pipeline, say and realtime generation); lk.end_of_turn_delay, lk.transcription_delay and lk.on_user_turn_completed_delay next to lk.e2e_latency on the reply's turn. Units: every duration attribute on a span is in seconds, as in Python. lk.eou.endpointing_delay (eou_detection, eou_wait), lk.eou.detection_delay, lk.transcription_delay and lk.end_of_turn_delay (user_turn), and lk.amd.speech_duration / lk.amd.delay were stamped in milliseconds before, which put them at odds with the new attributes and with the Python SDK on shared dashboards. Adaptations: Agent.id stands in for Python's Agent.label on the hook span; the user hook's non-StopResponse errors keep the existing JS behavior of logging and continuing with the reply (Python drops the turn); the realtime reply task records no queue wait, like Python. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
davidzhao
force-pushed
the
dz/telemetry-eot-wait
branch
from
September 16, 2026 04:34
e6f3e52 to
4c929a4
Compare
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.
Port of livekit/agents#7130.
Description
eou_detectiononly covered the turn-detector inference, so the endpointing delay itself (often seconds) showed up as an empty gap betweenuser_turnandagent_turn. This makes the wait, the user hook, and the speech queue visible.eou_waitspan, one per user turn, child ofuser_turn:lk.eou.outcome(committed/user_resumed/dropped),lk.eou.wait_duration,lk.eou.rearm_count, the finallk.eou.endpointing_delay, and the lastlk.eou.source;rearmedevent instead of starting a new span;lk.eou.not_committed_countand keeps waiting; resumed speech ends the span at the speech start (user_resumedevent) andlk.eou.resume_countonuser_turncounts those; teardown drops it. A runningeou_detectionis closed with asupersededevent so it stays inside the wait. A turn-detection mode change to or frommanualdrops the pending wait.eou_detectionkeeps its name and now nests undereou_wait.on_user_turn_completedspan around the user hook that gates the reply, under theuser_turnit completes: recognition hands the openuser_turnspan to the activity, which ends it after the hook. Exceptions are recorded redaction-aware (session and job flags);StopResponseis an event.Per-turn breakdown on the reply's
agent_turn:lk.speech.queue_wait(scheduling to first generation authorization), pluslk.end_of_turn_delay,lk.transcription_delay,lk.on_user_turn_completed_delaynext tolk.e2e_latency.Changes Made
voice/audio_recognition.ts:eou_waitstate machine (ensureEouWaitSpan/endEouWaitSpan/releaseEouDetectionSpan/stampUserTurnResumes),EndOfTurnInfo.userTurnSpan/userTurnSpanAdopted, lazily-createduser_turnstarts at the earliest known anchor,updateOptionsnow cancels the pending decision on a manual mode switch.voice/agent_activity.ts:on_user_turn_completedspan, adopteduser_turnended after the hook,recordQueueWait,recordUserTurnStages.voice/speech_handle.ts: scheduled / authorized timestamps and the queue-wait accessor.telemetry/trace_types.ts: seven new attributes (none PII); unit docs on the existing delay attributes.voice/amd.ts: AMD duration attributes converted to seconds.Adaptations from the Python source
lk.agent_labelusesagent.id(JS agents have nolabel), like every other JS site.StopResponsehook error keeps the existing JS behavior (log, record on the span, continue to the reply); Python drops the turn. Left unchanged to keep this PR to telemetry.lk.eou.endpointing_delay(eou_detection,eou_wait),lk.eou.detection_delay,lk.transcription_delay/lk.end_of_turn_delay(user_turn), andlk.amd.speech_duration/lk.amd.delaywere stamped in milliseconds before, which put them at odds with the new attributes and with the Python SDK on shared dashboards. Called out in the changeset.Testing
voice/eou_wait_span.test.ts(10 tests): commit, re-arm, resumed speech, teardown drop, not-committed, nested and supersededeou_detection, manual mode switch, and a full fake session asserting the wait, the hook span, the queue wait and session-only redaction of a hook exception.audio_recognition_span.test.tsparenting assertions updated (eou_detection→eou_wait→user_turn).agentssuite green; build, typecheck, lint, API report updated.🤖 Generated with Claude Code