fix(voice): clamp the user_speaking span end to its start - #2536
Open
rosetta-livekit-bot[bot] wants to merge 3 commits into
Open
rosetta-livekit-bot[bot] wants to merge 3 commits into
rosetta-livekit-bot[bot] wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: c9835da 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 |
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.
Summary
user_speakingspan end to the recorded span start@livekit/agentsPorts livekit/agents#7332. Fixes livekit/agents#7307.
Testing
pnpm test agents/src/voice/audio_recognition_span.test.ts(11 passed)pnpm --filter @livekit/agents typecheckpnpm --filter @livekit/agents buildpnpm build(40 workspace packages built)pnpm --filter @livekit/agents lint(passes with existing warnings)pnpm exec prettier --check "agents/src/**/*.{ts,tsx,md,json}"pnpm test agents(2,721 passed, 5 skipped; 3 unrelatedagents/src/telemetry/loop_monitor.test.tsfailures because this host falls back to process CPU accounting while those tests require thread CPU accounting)cue-clivoice validation attempted; the configured LiveKit endpoint rejected both the worker and driven turn with401 Unauthorized - invalid API key, so framework-event validation could not completeSource diff coverage
Classification of every file in livekit/agents#7332
livekit-agents/livekit/agents/voice/agent_session.pyagents/src/voice/agent_session.ts: stores the explicit millisecond start anchor alongside the span and clamps the end against it, keeping the behavior independent of the tracer provider's span implementation.tests/test_user_speaking_span.pyagents/src/voice/audio_recognition_span.test.ts: ports both source cases into the existing JS span-test counterpart, covering a 550 ms backdated end and an unchanged 1,250 ms positive duration.tests/trace_schema.pytests/test_trace_schema.pyNo source runtime behavior depends on the Python-only validator omitted above.
Ported from livekit/agents#7332
Original PR description
Problem: The
user_speakingspan starts on the STT turn anchor and ends on a VAD anchor that is backdated bysilence_duration + inference_duration. The two detectors do not share a clock, so on a short burst the end lands before the start, and OpenTelemetry keeps the duration unsigned — the reporter's backend read18446744073500970us.Fix: The end is clamped to the span start, so the span is zero-length instead of negative.
check_traceintests/trace_schema.pynow reports any span that ends before it starts.Fixes #7307.
Context for reviewing and coding agents