Skip to content

feat: correlate telemetry spans with the conversation - #2641

Merged
chenghao-mou merged 2 commits into
mainfrom
boutique-pristine-partisan
Oct 13, 2026
Merged

chenghao-mou merged 2 commits into
mainfrom
boutique-pristine-partisan

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Ports livekit/agents#7533.

Summary

  • attach the current room SID as gen_ai.conversation.id when the LiveKit tracer starts any span
  • preserve explicit conversation IDs and immutable caller attributes
  • keep later GenAI attribute setters from replacing the span-start correlation ID

Testing

  • npx -y node@22 /usr/local/lib/node_modules/pnpm/bin/pnpm.cjs test agents (3,097 passed, 5 skipped)
  • pnpm build
  • pnpm lint
  • pnpm format:check
  • pnpm --filter @livekit/agents api:check
Source diff coverage
  • livekit-agents/livekit/agents/telemetry/gen_ai.py: adapted to agents/src/telemetry/gen_ai.ts; removed conversation-ID writes from the four GenAI attribute setters so later setter calls cannot overwrite an explicit or span-start value.
  • livekit-agents/livekit/agents/telemetry/traces.py: adapted to agents/src/telemetry/traces.ts and agents/src/telemetry/utils.ts; injects the current room SID through every JS dynamic-tracer span API, covers the target-only synchronous active-span API, preserves caller-supplied IDs and immutable attributes, and routes the one raw internal tracer call through the wrapper.
  • tests/test_telemetry_conversation_id.py: ported to agents/src/telemetry/conversation_id.test.ts; retains the source matrix for absent/current/explicit IDs, caller-attribute immutability, all target tracer APIs, and repeated GenAI setter calls.
  • tests/test_telemetry_gen_ai.py: not applicable as a deletion; agents/src/telemetry/gen_ai.test.ts does not contain the source tool-only conversation-ID test that the source PR removes. The new cross-setter test supersedes that behavior.
  • tests/test_telemetry_metadata.py: adapted into agents/src/telemetry/conversation_id.test.ts; JS has a different job-metadata processor lifecycle, so the changed assertion is tested directly by verifying the room SID inside job context and omission outside it.

Ported from livekit/agents#7533

Original PR description

Spans from speech processing and tools need the same conversation ID for session grouping. Attach the room SID through the LiveKit tracer, preserve explicit IDs, and omit the field outside a job.

Adapts @SanjuMLGeek’s proposal in #7396 and handles positional attributes without mutating caller mappings.

Stacked on livekit/agents#7532.

Addresses AGT-3603

Request summary and agent context

Model: GPT-6-Astra

Split the proposed telemetry improvements into focused PRs that are easy to review and revert. Use general problem summaries and omit customer details.

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner October 4, 2026 20:47
@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30fda80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-meta Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

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

devin-ai-integration[bot]

This comment was marked as resolved.

Set the root span's conversation ID from the assigned job room, since this
span starts before the job context is active.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@chenghao-mou chenghao-mou added the review_effort:medium Focused changes that need domain context or careful validation label Oct 13, 2026
@chenghao-mou
chenghao-mou merged commit 6f29065 into main Oct 13, 2026
9 checks passed
@chenghao-mou
chenghao-mou deleted the boutique-pristine-partisan branch October 13, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review_effort:medium Focused changes that need domain context or careful validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant