perf: skip discarded trace payload construction - #2463
Open
rosetta-livekit-bot[bot] wants to merge 3 commits into
Open
perf: skip discarded trace payload construction#2463rosetta-livekit-bot[bot] wants to merge 3 commits into
rosetta-livekit-bot[bot] wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 427337c The changes in this PR will be included in the next version bump. This PR includes changesets to release 38 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.
Ports livekit/agents#7155.
Avoid constructing GenAI input/output payloads when spans are not recording or content capture is disabled. Preserve non-content request, response, usage, and legacy trace attributes, and avoid telemetry-only response accumulation when content will be discarded.
Source diff coverage
livekit-agents/livekit/agents/llm/llm.py: adapted toagents/src/llm/llm.ts. Snapshot span recording/content-capture state atllm_requeststart, skip eager request/output builders, and skip telemetry-only response accumulation. The target lacked Python's existing capture-state getter, soagents/src/telemetry/gen_ai.tsaddscaptureContentEnabled()andagents/etc/agents.api.mdrecords the public API.livekit-agents/livekit/agents/voice/generation.py: adapted toagents/src/voice/generation.ts. Guard legacy chat/tool serialization on span recording and uninstrumented GenAI content builders on recording plus capture enablement.tests/test_llm_telemetry.py: adapted acrossagents/src/llm/llm.test.tsandagents/src/voice/generation_telemetry.test.tsto match target test organization. All source-added/modified cases are covered: cached-token/content attributes, capture toggles, disabled/nonrecording stream payload construction and accumulation, nonrecordingllm_nodeserialization, and disabled-capture non-content attributes.Validation
pnpm test agents(2,514 passed, 5 skipped)pnpm buildpnpm lint(passes with pre-existing repository warnings)pnpm format:checkpnpm --filter @livekit/agents typecheckpnpm --filter @livekit/agents api:checkcue-cliruntime validation was attempted after the full build, but the configured LiveKit environment rejected worker authentication with HTTP 401, so no framework-event run could be completed.A minor changeset is included for the new public
genAI.captureContentEnabled()API.Ported from livekit/agents#7155
Original PR description
Tracing builds large chat and GenAI payloads before OpenTelemetry decides to discard them. Check span recording and content capture first, while retaining legacy chat context, recorded content, and non-content metrics.
A 1,000-message sampled-out
llm_nodedrops from 4.1 ms to 84 µs locally.Addresses AGT-3452
Initial prompt and agent context
Model: GPT-5.6